Skip to content

Commit

Permalink
refactor!: Changes to SeedFinderOrthogonal to allow reuse of the obje…
Browse files Browse the repository at this point in the history
…ct (#1757)

This PR applies similar changes to these in #1693 . As a result the SeedFinderOrthogonal does not need to be recreated for every event. 

Closes #1690

BREAKING CHANGE 
Method to crate OthogonalSeedFinder and createSeeds are modified. The former does not take SeedOptions while the later does now.
  • Loading branch information
tboldagh authored Jan 18, 2023
1 parent 44c571c commit 77b55d0
Show file tree
Hide file tree
Showing 11 changed files with 191 additions and 142 deletions.
Binary file modified CI/physmon/reference/performance_ambi_orthogonal.root
Binary file not shown.
Binary file modified CI/physmon/reference/performance_ckf_orthogonal.root
Binary file not shown.
Binary file modified CI/physmon/reference/performance_seeding_hists_orthogonal.root
Binary file not shown.
Binary file modified CI/physmon/reference/performance_vertexing_orthogonal_hist.root
Binary file not shown.
7 changes: 4 additions & 3 deletions Core/include/Acts/Seeding/SeedFinderConfig.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,7 @@ struct SeedFinderConfig {
Delegate<Acts::Vector3(const SpacePoint&)> getTopStripCenterPosition;

bool isInInternalUnits = false;

SeedFinderConfig toInternalUnits() const {
if (isInInternalUnits) {
throw std::runtime_error(
Expand Down Expand Up @@ -247,9 +248,9 @@ struct SeedFinderOptions {
options.bFieldInZ /= 1000. * 1_T;
return options;
}
template <typename SpacePoint>
SeedFinderOptions calculateDerivedQuantities(
const SeedFinderConfig<SpacePoint>& config) const {

template <typename Config>
SeedFinderOptions calculateDerivedQuantities(const Config& config) const {
if (!isInInternalUnits) {
throw std::runtime_error(
"Derived quantities in SeedFinderOptions can only be calculated from "
Expand Down
40 changes: 23 additions & 17 deletions Core/include/Acts/Seeding/SeedFinderOrthogonal.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,13 @@

#include "Acts/Seeding/InternalSeed.hpp"
#include "Acts/Seeding/InternalSpacePoint.hpp"
#include "Acts/Seeding/SeedFilter.hpp"
#include "Acts/Seeding/SeedFinderConfig.hpp"
#include "Acts/Seeding/SeedFinderOrthogonalConfig.hpp"
#include "Acts/Utilities/KDTree.hpp"

#include <array>
#include <iostream>
#include <list>
#include <map>
#include <memory>
Expand Down Expand Up @@ -55,25 +58,20 @@ class SeedFinderOrthogonal {
* @brief Construct a new orthogonal seed finder.
*
* @param config The configuration parameters for this seed finder.
* @param options frequently changing configuration (like beam position)
*/
SeedFinderOrthogonal(
const Acts::SeedFinderOrthogonalConfig<external_spacepoint_t> &config,
const Acts::SeedFinderOptions &options);
const Acts::SeedFinderOrthogonalConfig<external_spacepoint_t> &config);

/**
* @brief Destroy the orthogonal seed finder object.
*/
~SeedFinderOrthogonal() = default;

/*
* Disallow various kinds of constructors, copies, and assignments.
*/
SeedFinderOrthogonal() = delete;
SeedFinderOrthogonal() = default;
SeedFinderOrthogonal(const SeedFinderOrthogonal<external_spacepoint_t> &) =
delete;
SeedFinderOrthogonal<external_spacepoint_t> &operator=(
const SeedFinderOrthogonal<external_spacepoint_t> &) = delete;
const SeedFinderOrthogonal<external_spacepoint_t> &) = default;

/**
* @brief Perform seed finding, appending seeds to a container.
Expand All @@ -98,14 +96,16 @@ class SeedFinderOrthogonal {
* @tparam input_container_t The type of the input spacepoint container.
* @tparam output_container_t The type of the output seed container.
*
* @param options frequently changing configuration (like beam position)
* @param spacePoints The input spacepoints from which to create seeds.
* @param out_cont The output container to write seeds to.
* @param extract_coordinates User-defined function for extracting global position and
* covariance of the external space point
*/
template <typename input_container_t, typename output_container_t,
typename callable_t>
void createSeeds(const input_container_t &spacePoints,
void createSeeds(const Acts::SeedFinderOptions &options,
const input_container_t &spacePoints,
output_container_t &out_cont,
callable_t &&extract_coordinates) const;

Expand All @@ -118,15 +118,16 @@ class SeedFinderOrthogonal {
* about the seeding algorithm, please see that function.
*
* @tparam input_container_t The type of the input spacepoint container.
*
* @param options frequently changing configuration (like beam position)
* @param spacePoints The input spacepoints from which to create seeds.
* @param extract_coordinates User-defined function for extracting global position and
* covariance of the external space point
*
* @return A vector of seeds.
*/
template <typename input_container_t, typename callable_t>
std::vector<seed_t> createSeeds(const input_container_t &spacePoints,
std::vector<seed_t> createSeeds(const Acts::SeedFinderOptions &options,
const input_container_t &spacePoints,
callable_t &&extract_coordinates) const;

private:
Expand Down Expand Up @@ -180,12 +181,14 @@ class SeedFinderOrthogonal {
* pairs of points that were not generated using a constrained spatial search
* strategy.
*
* @param options frequently changing configuration (like beam position)
* @param low The lower spacepoint.
* @param high The upper spacepoint.
*
* @return True if the two points form a valid pair, false otherwise.
*/
bool validTuple(const internal_sp_t &low, const internal_sp_t &high) const;
bool validTuple(const SeedFinderOptions &options, const internal_sp_t &low,
const internal_sp_t &high) const;

/**
* @brief Create a k-d tree from a set of spacepoints.
Expand All @@ -200,22 +203,25 @@ class SeedFinderOrthogonal {
* @brief Filter potential candidate pairs, and output seeds into an
* iterator.
*
* @param options frequently changing configuration (like beam position)
* @param middle The (singular) middle spacepoint.
* @param bottom The (vector of) candidate bottom spacepoints.
* @param top The (vector of) candidate top spacepoints.
* @param seedFilterState holds quantities used in seed filter
* @param candidates_collector The container to write the resulting
* seed caandidates to.
* seed candidates to.
*/
void filterCandidates(
internal_sp_t &middle, std::vector<internal_sp_t *> &bottom,
std::vector<internal_sp_t *> &top, SeedFilterState seedFilterState,
const SeedFinderOptions &options, internal_sp_t &middle,
std::vector<internal_sp_t *> &bottom, std::vector<internal_sp_t *> &top,
SeedFilterState seedFilterState,
CandidatesForMiddleSp<InternalSpacePoint<external_spacepoint_t>>
&candidates_collector) const;

/**
* @brief Search for seeds starting from a given middle space point.
*
* @param options frequently changing configuration (like beam position)
* @tparam NDims Number of dimensions for our spatial embedding (probably 3).
* @tparam output_container_t Type of the output container.
*
Expand All @@ -224,14 +230,14 @@ class SeedFinderOrthogonal {
* @param middle_p The middle spacepoint to find seeds for.
*/
template <typename output_container_t>
void processFromMiddleSP(const tree_t &tree, output_container_t &out_cont,
void processFromMiddleSP(const SeedFinderOptions &options, const tree_t &tree,
output_container_t &out_cont,
const typename tree_t::pair_t &middle_p) const;

/**
* @brief The configuration for the seeding algorithm.
*/
Acts::SeedFinderOrthogonalConfig<external_spacepoint_t> m_config;
Acts::SeedFinderOptions m_options;
};
} // namespace Acts

Expand Down
Loading

0 comments on commit 77b55d0

Please sign in to comment.