Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-06-30 07:51:51

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/Seeding/BinnedGroup.hpp"
0012 #include "Acts/Seeding/SeedFinderConfig.hpp"
0013 #include "Acts/Utilities/Grid.hpp"
0014 #include "Acts/Utilities/Logger.hpp"
0015 
0016 #include <numbers>
0017 #include <vector>
0018 
0019 namespace Acts {
0020 
0021 /// Concept to check the provided external space point type
0022 /// can be used to fill the space point grid
0023 template <typename external_spacepoint_t>
0024 concept CylindricalGridElement = requires(external_spacepoint_t sp) {
0025   { sp.phi() } -> std::same_as<float>;
0026   { sp.z() } -> std::same_as<float>;
0027   { sp.radius() } -> std::same_as<float>;
0028 };
0029 
0030 /// Cylindrical Space Point bin is a 2D grid with (phi, z) bins
0031 /// It stores a vector of internal space points to external space points
0032 template <CylindricalGridElement external_spacepoint_t>
0033 using CylindricalSpacePointGrid =
0034     Grid<std::vector<const external_spacepoint_t*>,
0035          Axis<AxisType::Equidistant, AxisBoundaryType::Closed>,
0036          Axis<AxisType::Variable, AxisBoundaryType::Open>,
0037          Axis<AxisType::Variable, AxisBoundaryType::Open>>;
0038 
0039 /// Cylindrical Binned Group
0040 template <typename external_spacepoint_t>
0041 using CylindricalBinnedGroup =
0042     BinnedGroup<CylindricalSpacePointGrid<external_spacepoint_t>>;
0043 
0044 template <typename external_spacepoint_t>
0045 using CylindricalBinnedGroupIterator =
0046     BinnedGroupIterator<CylindricalSpacePointGrid<external_spacepoint_t>>;
0047 
0048 struct CylindricalSpacePointGridConfig {
0049   // minimum pT to be found by seedFinder
0050   float minPt = 0 * UnitConstants::MeV;
0051   // maximum extension of sensitive detector layer relevant for seeding as
0052   // distance from x=y=0 (i.e. in r)
0053   float rMax = 320 * UnitConstants::mm;
0054   // maximum extension of sensitive detector layer relevant for seeding as
0055   // distance from x=y=0 (i.e. in r)
0056   float rMin = 0 * UnitConstants::mm;
0057   // maximum extension of sensitive detector layer relevant for seeding in
0058   // positive direction in z
0059   float zMax = 0 * UnitConstants::mm;
0060   // maximum extension of sensitive detector layer relevant for seeding in
0061   // negative direction in z
0062   float zMin = 0 * UnitConstants::mm;
0063   // maximum distance in r from middle space point to bottom or top spacepoint
0064   float deltaRMax = 0 * UnitConstants::mm;
0065   // maximum forward direction expressed as cot(theta)
0066   float cotThetaMax = 0;
0067   // maximum impact parameter in mm
0068   float impactMax = 0 * UnitConstants::mm;
0069   // minimum phi value for phiAxis construction
0070   float phiMin = -std::numbers::pi_v<float>;
0071   // maximum phi value for phiAxis construction
0072   float phiMax = std::numbers::pi_v<float>;
0073   // Multiplicator for the number of phi-bins. The minimum number of phi-bins
0074   // depends on min_pt, magnetic field: 2*pi/(minPT particle phi-deflection).
0075   // phiBinDeflectionCoverage is a multiplier for this number. If
0076   // numPhiNeighbors (in the configuration of the BinFinders) is configured to
0077   // return 1 neighbor on either side of the current phi-bin (and you want to
0078   // cover the full phi-range of minPT), leave this at 1.
0079   int phiBinDeflectionCoverage = 1;
0080   // maximum number of phi bins
0081   int maxPhiBins = 10000;
0082   // enable non equidistant binning in z
0083   std::vector<float> zBinEdges{};
0084   std::vector<float> rBinEdges{};
0085 
0086   bool isInInternalUnits = true;
0087   //[[deprecated("CylindricalSpacePointGridConfig uses internal units")]]
0088   CylindricalSpacePointGridConfig toInternalUnits() const { return *this; }
0089 
0090   void checkConfig() const {
0091     if (phiMin < -std::numbers::pi_v<float> ||
0092         phiMax > std::numbers::pi_v<float>) {
0093       throw std::runtime_error(
0094           "CylindricalSpacePointGridConfig: phiMin (" + std::to_string(phiMin) +
0095           ") and/or phiMax (" + std::to_string(phiMax) +
0096           ") are outside the allowed phi range, defined as "
0097           "[-std::numbers::pi_v<float>, std::numbers::pi_v<float>]");
0098     }
0099     if (phiMin > phiMax) {
0100       throw std::runtime_error(
0101           "CylindricalSpacePointGridConfig: phiMin is bigger then phiMax");
0102     }
0103     if (rMin > rMax) {
0104       throw std::runtime_error(
0105           "CylindricalSpacePointGridConfig: rMin is bigger then rMax");
0106     }
0107     if (zMin > zMax) {
0108       throw std::runtime_error(
0109           "CylindricalSpacePointGridConfig: zMin is bigger than zMax");
0110     }
0111   }
0112 };
0113 
0114 struct CylindricalSpacePointGridOptions {
0115   // magnetic field
0116   float bFieldInZ = 0 * UnitConstants::T;
0117 
0118   bool isInInternalUnits = true;
0119   //[[deprecated("CylindricalSpacePointGridOptions uses internal units")]]
0120   CylindricalSpacePointGridOptions toInternalUnits() const { return *this; }
0121 };
0122 
0123 /// Instructions on how to create and fill this grid specialization
0124 class CylindricalSpacePointGridCreator {
0125  public:
0126   template <typename external_spacepoint_t>
0127   static CylindricalSpacePointGrid<external_spacepoint_t> createGrid(
0128       const CylindricalSpacePointGridConfig& _config,
0129       const CylindricalSpacePointGridOptions& _options,
0130       const Logger& logger = getDummyLogger());
0131 
0132   template <typename external_spacepoint_t,
0133             typename external_spacepoint_iterator_t>
0134   static void fillGrid(const SeedFinderConfig<external_spacepoint_t>& config,
0135                        const SeedFinderOptions& options,
0136                        CylindricalSpacePointGrid<external_spacepoint_t>& grid,
0137                        external_spacepoint_iterator_t spBegin,
0138                        external_spacepoint_iterator_t spEnd,
0139                        const Logger& logger = getDummyLogger());
0140 
0141   template <typename external_spacepoint_t, typename external_collection_t>
0142     requires std::ranges::range<external_collection_t> &&
0143              std::same_as<typename external_collection_t::value_type,
0144                           external_spacepoint_t>
0145   static void fillGrid(const SeedFinderConfig<external_spacepoint_t>& config,
0146                        const SeedFinderOptions& options,
0147                        CylindricalSpacePointGrid<external_spacepoint_t>& grid,
0148                        const external_collection_t& collection,
0149                        const Logger& logger = getDummyLogger());
0150 };
0151 
0152 }  // namespace Acts
0153 
0154 #include "Acts/Seeding/detail/CylindricalSpacePointGrid.ipp"