Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-11-07 09:43:53

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/Units.hpp"
0012 #include "Acts/EventData/SpacePointContainer.hpp"
0013 #include "Acts/Seeding/detail/SpacePointGridBase.hpp"
0014 #include "Acts/Utilities/Grid.hpp"
0015 #include "Acts/Utilities/Logger.hpp"
0016 #include "Acts/Utilities/RangeXD.hpp"
0017 
0018 #include <numbers>
0019 #include <vector>
0020 
0021 namespace Acts {
0022 
0023 /// A cylindrical space point grid used for seeding in a cylindrical detector
0024 /// geometry.
0025 /// The grid is defined in cylindrical coordinates (phi, z, r) and allows for
0026 /// efficient access to space points based on their azimuthal angle,
0027 /// z-coordinate, and radial distance.
0028 class CylindricalSpacePointGrid
0029     : public detail::SpacePointGridBase<
0030           CylindricalSpacePointGrid,
0031           Grid<std::vector<std::uint32_t>,
0032                Axis<AxisType::Equidistant, AxisBoundaryType::Closed>,
0033                Axis<AxisType::Variable, AxisBoundaryType::Open>,
0034                Axis<AxisType::Variable, AxisBoundaryType::Open>>> {
0035  public:
0036   /// Type alias for the CRTP base class
0037   using GridBase =
0038       detail::SpacePointGridBase<CylindricalSpacePointGrid, GridType>;
0039   /// Type alias for the phi axis (equidistant binning, closed boundaries)
0040   using PhiAxisType = GridBase::AxisTypeAt<0>;
0041   /// Type alias for the z axis (variable binning, open boundaries)
0042   using ZAxisType = GridBase::AxisTypeAt<1>;
0043   /// Type alias for the r axis (variable binning, open boundaries)
0044   using RAxisType = GridBase::AxisTypeAt<2>;
0045 
0046   /// Configuration parameters for the cylindrical space point grid.
0047   struct Config {
0048     /// minimum pT
0049     float minPt = 0 * UnitConstants::MeV;
0050     /// minimum extension of sensitive detector layer relevant for seeding as
0051     /// distance from x=y=0 (i.e. in r)
0052     /// WARNING: if rMin is smaller than impactMax, the bin size will be 2*pi,
0053     /// which will make seeding very slow!
0054     float rMin = 0 * UnitConstants::mm;
0055     /// maximum extension of sensitive detector layer relevant for seeding as
0056     /// distance from x=y=0 (i.e. in r)
0057     float rMax = 600 * UnitConstants::mm;
0058     /// minimum extension of sensitive detector layer relevant for seeding in
0059     /// negative direction in z
0060     float zMin = -2800 * UnitConstants::mm;
0061     /// maximum extension of sensitive detector layer relevant for seeding in
0062     /// positive direction in z
0063     float zMax = 2800 * UnitConstants::mm;
0064     /// maximum distance in r from middle space point to bottom or top
0065     /// space point
0066     float deltaRMax = 270 * UnitConstants::mm;
0067     /// maximum forward direction expressed as cot(theta)
0068     float cotThetaMax = 10.01788;  // equivalent to eta = 3 (pseudorapidity)
0069     /// maximum impact parameter in mm
0070     float impactMax = 0 * UnitConstants::mm;
0071     /// minimum phi value for phiAxis construction
0072     float phiMin = -std::numbers::pi_v<float>;
0073     /// maximum phi value for phiAxis construction
0074     float phiMax = std::numbers::pi_v<float>;
0075     /// Multiplicator for the number of phi-bins. The minimum number of phi-bins
0076     /// depends on min_pt, magnetic field: 2*pi/(minPT particle phi-deflection).
0077     /// phiBinDeflectionCoverage is a multiplier for this number. If
0078     /// numPhiNeighbors (in the configuration of the BinFinders) is configured
0079     /// to return 1 neighbor on either side of the current phi-bin (and you want
0080     /// to cover the full phi-range of minPT), leave this at 1.
0081     int phiBinDeflectionCoverage = 1;
0082     /// maximum number of phi bins
0083     int maxPhiBins = 10000;
0084     /// enable non equidistant binning in z
0085     std::vector<float> zBinEdges{};
0086     /// enable non equidistant binning in r
0087     std::vector<float> rBinEdges{};
0088 
0089     /// magnetic field
0090     float bFieldInZ = 0 * UnitConstants::T;
0091 
0092     /// bin finder for bottom space points
0093     std::optional<GridBinFinder<3ul>> bottomBinFinder;
0094     /// bin finder for top space points
0095     std::optional<GridBinFinder<3ul>> topBinFinder;
0096     /// navigation structure for the grid
0097     std::array<std::vector<std::size_t>, 3ul> navigation;
0098   };
0099 
0100   /// Construct a cylindrical space point grid with the given configuration and
0101   /// an optional logger.
0102   /// @param config Configuration for the cylindrical grid
0103   /// @param logger Optional logger instance for debugging output
0104   explicit CylindricalSpacePointGrid(
0105       const Config& config,
0106       std::unique_ptr<const Logger> logger =
0107           getDefaultLogger("CylindricalSpacePointGrid", Logging::Level::INFO));
0108 
0109   using GridBase::binIndex;
0110   /// Get the bin index for a space point given its azimuthal angle, radial
0111   /// distance, and z-coordinate.
0112   /// @param phi The azimuthal angle of the space point in radians
0113   /// @param z The z-coordinate of the space point
0114   /// @param r The radial distance of the space point from the origin
0115   /// @return The index of the bin in which the space point is located, or
0116   ///         `std::nullopt` if the space point is outside the grid bounds.
0117   std::optional<std::size_t> binIndex(float phi, float z, float r) const {
0118     return binIndex(Vector3(phi, z, r));
0119   }
0120 
0121   using GridBase::insert;
0122   /// Insert a space point into the grid.
0123   /// @param index The index of the space point to insert
0124   /// @param phi The azimuthal angle of the space point in radians
0125   /// @param z The z-coordinate of the space point
0126   /// @param r The radial distance of the space point from the origin
0127   /// @return The index of the bin in which the space point was inserted, or
0128   ///         `std::nullopt` if the space point is outside the grid bounds.
0129   std::optional<std::size_t> insert(SpacePointIndex index, float phi, float z,
0130                                     float r) {
0131     return insert(index, Vector3(phi, z, r));
0132   }
0133   /// Insert a space point into the grid.
0134   /// @param sp The space point to insert
0135   /// @return The index of the bin in which the space point was inserted, or
0136   ///         `std::nullopt` if the space point is outside the grid bounds.
0137   std::optional<std::size_t> insert(const ConstSpacePointProxy& sp) {
0138     return insert(sp.index(), sp.phi(), sp.z(), sp.r());
0139   }
0140 
0141   /// Sort the bins in the grid by the space point radius, which is required by
0142   /// some algorithms that operate on the grid.
0143   /// @param spacePoints The space point container to sort the bins by radius
0144   void sortBinsByR(const SpacePointContainer& spacePoints);
0145 
0146   /// Compute the range of radii in the grid. This requires the grid to be
0147   /// filled with space points and sorted by radius. The sorting can be done
0148   /// with the `sortBinsByR` method.
0149   /// @param spacePoints The space point container to compute the radius range
0150   /// @return The range of radii in the grid
0151   Range1D<float> computeRadiusRange(
0152       const SpacePointContainer& spacePoints) const;
0153 
0154  private:
0155   Config m_cfg;
0156 };
0157 
0158 }  // namespace Acts