Skip to content

Commit

Permalink
Merge branch 'main' into CorrectImpactComputation
Browse files Browse the repository at this point in the history
  • Loading branch information
CarloVarni authored Oct 15, 2024
2 parents 32d490b + fb3ddf4 commit bbc04ea
Show file tree
Hide file tree
Showing 18 changed files with 414 additions and 291 deletions.
13 changes: 13 additions & 0 deletions Core/include/Acts/Geometry/CylinderVolumeBounds.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#pragma once

#include "Acts/Definitions/Algebra.hpp"
#include "Acts/Geometry/BoundarySurfaceFace.hpp"
#include "Acts/Geometry/Volume.hpp"
#include "Acts/Geometry/VolumeBounds.hpp"
#include "Acts/Utilities/BinningType.hpp"
Expand Down Expand Up @@ -80,6 +81,18 @@ class CylinderVolumeBounds : public VolumeBounds {
eSize
};

/// Enum describing the possible faces of a cylinder volume
/// @note These values are synchronized with the BoundarySurfaceFace enum.
/// Once Gen1 is removed, this can be changed.
enum class Face : unsigned int {
PositiveDisc = BoundarySurfaceFace::positiveFaceXY,
NegativeDisc = BoundarySurfaceFace::negativeFaceXY,
OuterCylinder = BoundarySurfaceFace::tubeOuterCover,
InnerCylinder = BoundarySurfaceFace::tubeInnerCover,
NegativePhiPlane = BoundarySurfaceFace::tubeSectorNegativePhi,
PositivePhiPlane = BoundarySurfaceFace::tubeSectorPositivePhi
};

CylinderVolumeBounds() = delete;

/// Constructor
Expand Down
18 changes: 4 additions & 14 deletions Core/include/Acts/Geometry/PortalShell.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

#pragma once

#include "Acts/Geometry/BoundarySurfaceFace.hpp"
#include "Acts/Geometry/CylinderVolumeBounds.hpp"
#include "Acts/Utilities/BinningType.hpp"
#include "Acts/Utilities/Logger.hpp"

Expand Down Expand Up @@ -68,19 +68,9 @@ class PortalShellBase {
/// volumes
class CylinderPortalShell : public PortalShellBase {
public:
/// Enum describing the possible faces of a cylinder portal shell
/// @note These values are synchronized with the BoundarySurfaceFace enum.
/// Once Gen1 is removed, this can be changed.
enum class Face : unsigned int {
PositiveDisc = BoundarySurfaceFace::positiveFaceXY,
NegativeDisc = BoundarySurfaceFace::negativeFaceXY,
OuterCylinder = BoundarySurfaceFace::tubeOuterCover,
InnerCylinder = BoundarySurfaceFace::tubeInnerCover,
NegativePhiPlane = BoundarySurfaceFace::tubeSectorNegativePhi,
PositivePhiPlane = BoundarySurfaceFace::tubeSectorPositivePhi
};

using enum Face;
using Face = CylinderVolumeBounds::Face;

using enum CylinderVolumeBounds::Face;

/// Retrieve the portal associated to the given face. Can be nullptr if unset.
/// @param face The face to retrieve the portal for
Expand Down
39 changes: 27 additions & 12 deletions Core/include/Acts/Seeding/SeedFinder.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,32 @@
#include "Acts/Seeding/SeedFinderConfig.hpp"
#include "Acts/Seeding/SeedFinderUtils.hpp"
#include "Acts/Seeding/SpacePointGrid.hpp"
#include "Acts/Seeding/detail/UtilityFunctions.hpp"

#include <array>
#include <limits>
#include <list>
#include <map>
#include <memory>
#include <ranges>
#include <set>
#include <string>
#include <utility>
#include <vector>

namespace Acts {

template <typename Coll>
concept GridBinCollection =
std::ranges::random_access_range<Coll> &&
std::same_as<typename Coll::value_type, std::size_t>;

template <typename Coll, typename external_t, std::size_t N = 3ul>
concept CollectionStoresSeedsTo = requires(Coll coll, external_t sp) {
Acts::detail::pushBackOrInsertAtEnd(coll,
Acts::Seed<external_t, N>(sp, sp, sp));
};

enum class SpacePointCandidateType : short { eBottom, eTop };

enum class DetectorMeasurementInfo : short { eDefault, eDetailed };
Expand All @@ -44,32 +57,32 @@ class SeedFinder {
public:
struct SeedingState {
// bottom space point
std::vector<const external_spacepoint_t*> compatBottomSP;
std::vector<const external_spacepoint_t*> compatTopSP;
std::vector<const external_spacepoint_t*> compatBottomSP{};
std::vector<const external_spacepoint_t*> compatTopSP{};
// contains parameters required to calculate circle with linear equation
// ...for bottom-middle
std::vector<LinCircle> linCircleBottom;
std::vector<LinCircle> linCircleBottom{};
// ...for middle-top
std::vector<LinCircle> linCircleTop;
std::vector<LinCircle> linCircleTop{};

// create vectors here to avoid reallocation in each loop
std::vector<const external_spacepoint_t*> topSpVec;
std::vector<float> curvatures;
std::vector<float> impactParameters;
std::vector<const external_spacepoint_t*> topSpVec{};
std::vector<float> curvatures{};
std::vector<float> impactParameters{};

// managing seed candidates for SpM
CandidatesForMiddleSp<const external_spacepoint_t> candidates_collector;
CandidatesForMiddleSp<const external_spacepoint_t> candidates_collector{};

// managing doublet candidates
boost::container::small_vector<Acts::Neighbour<grid_t>,
Acts::detail::ipow(3, grid_t::DIM)>
bottomNeighbours;
bottomNeighbours{};
boost::container::small_vector<Acts::Neighbour<grid_t>,
Acts::detail::ipow(3, grid_t::DIM)>
topNeighbours;
topNeighbours{};

// Mutable variables for Space points used in the seeding
Acts::SpacePointMutableData spacePointMutableData;
Acts::SpacePointMutableData spacePointMutableData{};
};

/// The only constructor. Requires a config object.
Expand Down Expand Up @@ -97,7 +110,9 @@ class SeedFinder {
/// @param rMiddleSPRange range object containing the minimum and maximum r for middle SP for a certain z bin.
/// @note Ranges must return pointers.
/// @note Ranges must be separate objects for each parallel call.
template <typename container_t, typename sp_range_t>
template <typename container_t, Acts::GridBinCollection sp_range_t>
requires Acts::CollectionStoresSeedsTo<container_t, external_spacepoint_t,
3ul>
void createSeedsForGroup(const Acts::SeedFinderOptions& options,
SeedingState& state, const grid_t& grid,
container_t& outputCollection,
Expand Down
4 changes: 3 additions & 1 deletion Core/include/Acts/Seeding/SeedFinder.ipp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,9 @@ SeedFinder<external_spacepoint_t, grid_t, platform_t>::SeedFinder(
}

template <typename external_spacepoint_t, typename grid_t, typename platform_t>
template <typename container_t, typename sp_range_t>
template <typename container_t, Acts::GridBinCollection sp_range_t>
requires Acts::CollectionStoresSeedsTo<container_t, external_spacepoint_t,
3ul>
void SeedFinder<external_spacepoint_t, grid_t, platform_t>::createSeedsForGroup(
const Acts::SeedFinderOptions& options, SeedingState& state,
const grid_t& grid, container_t& outputCollection,
Expand Down
30 changes: 28 additions & 2 deletions Core/include/Acts/Seeding/detail/CylindricalSpacePointGrid.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,18 @@

namespace Acts {

/// Concept to check the provided external space point type
/// can be used to fill the space point grid
template <typename external_spacepoint_t>
concept CylindricalGridElement = requires(external_spacepoint_t sp) {
{ sp.phi() } -> std::same_as<float>;
{ sp.z() } -> std::same_as<float>;
{ sp.radius() } -> std::same_as<float>;
};

/// Cylindrical Space Point bin is a 2D grid with (phi, z) bins
/// It stores a vector of internal space points to external space points
template <typename external_spacepoint_t>
template <Acts::CylindricalGridElement external_spacepoint_t>
using CylindricalSpacePointGrid = Acts::Grid<
std::vector<const external_spacepoint_t*>,
Acts::Axis<Acts::AxisType::Equidistant, Acts::AxisBoundaryType::Closed>,
Expand Down Expand Up @@ -90,6 +99,13 @@ struct CylindricalSpacePointGridConfig {
config.zMin /= 1_mm;
config.deltaRMax /= 1_mm;

for (float& val : config.zBinEdges) {
val /= 1_mm;
}
for (float& val : config.rBinEdges) {
val /= 1_mm;
}

if (config.phiMin < -std::numbers::pi_v<float> ||
config.phiMax > std::numbers::pi_v<float>) {
throw std::runtime_error(
Expand Down Expand Up @@ -119,7 +135,7 @@ struct CylindricalSpacePointGridConfig {

struct CylindricalSpacePointGridOptions {
// magnetic field
float bFieldInZ = 0.;
float bFieldInZ = 0. * Acts::UnitConstants::T;
bool isInInternalUnits = false;
CylindricalSpacePointGridOptions toInternalUnits() const {
if (isInInternalUnits) {
Expand Down Expand Up @@ -152,6 +168,16 @@ class CylindricalSpacePointGridCreator {
Acts::CylindricalSpacePointGrid<external_spacepoint_t>& grid,
external_spacepoint_iterator_t spBegin,
external_spacepoint_iterator_t spEnd);

template <typename external_spacepoint_t, typename external_collection_t>
requires std::ranges::range<external_collection_t> &&
std::same_as<typename external_collection_t::value_type,
external_spacepoint_t>
static void fillGrid(
const Acts::SeedFinderConfig<external_spacepoint_t>& config,
const Acts::SeedFinderOptions& options,
Acts::CylindricalSpacePointGrid<external_spacepoint_t>& grid,
const external_collection_t& collection);
};

} // namespace Acts
Expand Down
14 changes: 14 additions & 0 deletions Core/include/Acts/Seeding/detail/CylindricalSpacePointGrid.ipp
Original file line number Diff line number Diff line change
Expand Up @@ -214,3 +214,17 @@ void Acts::CylindricalSpacePointGridCreator::fillGrid(
std::ranges::sort(rbin, {}, [](const auto& rb) { return rb->radius(); });
}
}

template <typename external_spacepoint_t, typename external_collection_t>
requires std::ranges::range<external_collection_t> &&
std::same_as<typename external_collection_t::value_type,
external_spacepoint_t>
void Acts::CylindricalSpacePointGridCreator::fillGrid(
const Acts::SeedFinderConfig<external_spacepoint_t>& config,
const Acts::SeedFinderOptions& options,
Acts::CylindricalSpacePointGrid<external_spacepoint_t>& grid,
const external_collection_t& collection) {
Acts::CylindricalSpacePointGridCreator::fillGrid<external_spacepoint_t>(
config, options, grid, std::ranges::begin(collection),
std::ranges::end(collection));
}
17 changes: 12 additions & 5 deletions Core/include/Acts/Seeding/detail/UtilityFunctions.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,23 @@ concept isCollectionThatSupportsInsert =
};

// Define some functions
template <typename value_t>
void pushBackOrInsertAtEnd(
Acts::detail::isCollectionThatSupportsPushBack auto& storage,
value_t&& value) {
template <Acts::detail::isCollectionThatSupportsPushBack storage_t,
typename value_t>
requires requires(storage_t coll, value_t value) {
coll.push_back(value);
coll.push_back(std::move(value));
}
void pushBackOrInsertAtEnd(storage_t& storage, value_t&& value) {
storage.push_back(std::forward<value_t>(value));
}

template <std::ranges::range storage_t, typename value_t>
requires(!Acts::detail::isCollectionThatSupportsPushBack<storage_t> &&
Acts::detail::isCollectionThatSupportsInsert<storage_t>)
Acts::detail::isCollectionThatSupportsInsert<storage_t> &&
requires(storage_t coll, value_t value) {
coll.insert(std::ranges::end(coll), value);
coll.insert(std::ranges::end(coll), std::move(value));
})
void pushBackOrInsertAtEnd(storage_t& storage, value_t&& value) {
storage.insert(std::ranges::end(storage), std::forward<value_t>(value));
}
Expand Down
Loading

0 comments on commit bbc04ea

Please sign in to comment.