Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-11-18 09:56:20

0001 // This file is part of the ACTS project.
0002 //
0003 // Copyright (C) 2016 CERN for the benefit of the ACTS project
0004 //
0005 // This Source Code Form is subject to the terms of the Mozilla Public
0006 // License, v. 2.0. If a copy of the MPL was not distributed with this
0007 // file, You can obtain one at https://mozilla.org/MPL/2.0/.
0008 
0009 #pragma once
0010 
0011 #include "Acts/Definitions/Common.hpp"
0012 #include "Acts/Definitions/Direction.hpp"
0013 #include "Acts/Definitions/Units.hpp"
0014 #include "Acts/EventData/SpacePointContainer.hpp"
0015 #include "Acts/Seeding/detail/SpacePointGridBase.hpp"
0016 #include "Acts/Utilities/Grid.hpp"
0017 #include "Acts/Utilities/Logger.hpp"
0018 #include "Acts/Utilities/RangeXD.hpp"
0019 
0020 #include <functional>
0021 #include <vector>
0022 
0023 namespace Acts {
0024 
0025 /// A cartesian space point grid used for seeding in a cartesian detector
0026 /// geometry.
0027 /// The grid is defined in cartesian coordinates (x,y,z).
0028 class CartesianSpacePointGrid
0029     : public detail::SpacePointGridBase<
0030           CartesianSpacePointGrid,
0031           Grid<std::vector<std::uint32_t>,
0032                Axis<AxisType::Equidistant, AxisBoundaryType::Open>,
0033                Axis<AxisType::Equidistant, AxisBoundaryType::Open>,
0034                Axis<AxisType::Equidistant, AxisBoundaryType::Open>>> {
0035  public:
0036   /// Type alias for the CRTP base class
0037   using GridBase =
0038       detail::SpacePointGridBase<CartesianSpacePointGrid, GridType>;
0039   /// Type alias for the x axis (equidistant binning, open boundaries)
0040   using XAxisType = GridBase::AxisTypeAt<0>;
0041   /// Type alias for the y axis (equidistant binning, open boundaries)
0042   using YAxisType = GridBase::AxisTypeAt<1>;
0043   /// Type alias for the z axis (equidistant binning, open boundaries)
0044   using ZAxisType = GridBase::AxisTypeAt<2>;
0045 
0046   /// Configuration parameters for the cartesian space point grid.
0047   struct Config {
0048     /// number of bins in the x-coordinate
0049     int nXbins = 10;
0050     /// minimum x-coordinate of space points used in the seeding
0051     float xMin = -600 * UnitConstants::mm;
0052     /// maximum x-coordinate of space points used in the seeding
0053     float xMax = 600 * UnitConstants::mm;
0054     /// number of bins in the y-coordinate
0055     int nYbins = 6;
0056     /// minimum y-coordinate of space points used in the seeding
0057     float yMin = -600 * UnitConstants::mm;
0058     /// maximum y-coordinate of space points used in the seeding
0059     float yMax = 600 * UnitConstants::mm;
0060     /// number of bins in the z-coordinate
0061     int nZbins = 10;
0062     /// minimum z coordinate ofspace points used in the seeding
0063     float zMin = -2700 * UnitConstants::mm;
0064     /// maximum z coordinate ofspace points used in the seeding
0065     float zMax = 2700 * UnitConstants::mm;
0066 
0067     /// bin finder for bottom space points
0068     std::optional<GridBinFinder<3ul>> bottomBinFinder;
0069     /// bin finder for top space points
0070     std::optional<GridBinFinder<3ul>> topBinFinder;
0071     /// navigation structure for the grid
0072     std::array<std::vector<std::size_t>, 3ul> navigation;
0073 
0074     /// coordinate to sort the space points by
0075     Acts::CoordinateIndices sortingCoord = Acts::CoordinateIndices::eY;
0076 
0077     /// direction to sort the space points in
0078     Acts::Direction sortingDirection = Acts::Direction::Negative();
0079   };
0080 
0081   /// Construct a cartesian space point grid with the given configuration and
0082   /// an optional logger.
0083   /// @param config Configuration for the cartesian grid
0084   /// @param logger Optional logger instance for debugging output
0085   explicit CartesianSpacePointGrid(
0086       const Config& config,
0087       std::unique_ptr<const Logger> logger =
0088           getDefaultLogger("CartesianSpacePointGrid", Logging::Level::INFO));
0089 
0090   using GridBase::binIndex;
0091   /// Get the bin index for a space point given its x-, y-, and z-coordinate.
0092   /// @param x The x-coordinate of the space point
0093   /// @param y The y-coordinate of the space point
0094   /// @param z The z-coordinate of the space point
0095   /// @return The index of the bin in which the space point is located, or
0096   ///         `std::nullopt` if the space point is outside the grid bounds.
0097   std::optional<std::size_t> binIndex(float x, float y, float z) const {
0098     return binIndex(Vector3(x, y, z));
0099   }
0100 
0101   using GridBase::insert;
0102   /// Insert a space point into the grid.
0103   /// @param index The index of the space point to insert
0104   /// @param x The x-coordinate the space point
0105   /// @param y The y-coordinate the space point
0106   /// @param z The z-coordinate the space point
0107   /// @return The index of the bin in which the space point was inserted, or
0108   ///         `std::nullopt` if the space point is outside the grid bounds.
0109   std::optional<std::size_t> insert(SpacePointIndex index, float x, float y,
0110                                     float z) {
0111     return insert(index, Vector3(x, y, z));
0112   }
0113   /// Insert a space point into the grid.
0114   /// @param sp The space point to insert
0115   /// @return The index of the bin in which the space point was inserted, or
0116   ///         `std::nullopt` if the space point is outside the grid bounds.
0117   std::optional<std::size_t> insert(const ConstSpacePointProxy& sp) {
0118     return insert(sp.index(), sp.x(), sp.y(), sp.z());
0119   }
0120 
0121   /// Sort the bins in the grid by the space point sorting-coordinate, which is
0122   /// required by some algorithms that operate on the grid.
0123   /// @param spacePoints The space point container to sort the bins by the configured coordinate
0124   void sortBinsByCoord(const SpacePointContainer& spacePoints);
0125 
0126   /// Compute the range of the sorting coordinates in the grid. This requires
0127   /// the grid to be filled with space points and sorted by coordinate. The
0128   /// sorting can be done with the `sortBinsByCoord` method.
0129   /// @param spacePoints The space point container to compute the coordinate range
0130   /// @return The range of sorting-coordinate values in the grid
0131   Range1D<float> computeCoordRange(
0132       const SpacePointContainer& spacePoints) const;
0133 
0134  private:
0135   Config m_cfg;
0136 
0137   std::function<float(const ConstSpacePointProxy&)> m_sortCoordGetter;
0138 };
0139 
0140 }  // namespace Acts