Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:10:59

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 <Acts::CylindricalGridElement external_spacepoint_t>
0033 using CylindricalSpacePointGrid = Acts::Grid<
0034     std::vector<const external_spacepoint_t*>,
0035     Acts::Axis<Acts::AxisType::Equidistant, Acts::AxisBoundaryType::Closed>,
0036     Acts::Axis<Acts::AxisType::Variable, Acts::AxisBoundaryType::Open>,
0037     Acts::Axis<Acts::AxisType::Variable, Acts::AxisBoundaryType::Open>>;
0038 
0039 /// Cylindrical Binned Group
0040 template <typename external_spacepoint_t>
0041 using CylindricalBinnedGroup =
0042     Acts::BinnedGroup<Acts::CylindricalSpacePointGrid<external_spacepoint_t>>;
0043 
0044 template <typename external_spacepoint_t>
0045 using CylindricalBinnedGroupIterator = Acts::BinnedGroupIterator<
0046     Acts::CylindricalSpacePointGrid<external_spacepoint_t>>;
0047 
0048 struct CylindricalSpacePointGridConfig {
0049   // minimum pT to be found by seedFinder
0050   float minPt = 0 * Acts::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 * Acts::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 * Acts::UnitConstants::mm;
0057   // maximum extension of sensitive detector layer relevant for seeding in
0058   // positive direction in z
0059   float zMax = 0 * Acts::UnitConstants::mm;
0060   // maximum extension of sensitive detector layer relevant for seeding in
0061   // negative direction in z
0062   float zMin = 0 * Acts::UnitConstants::mm;
0063   // maximum distance in r from middle space point to bottom or top spacepoint
0064   float deltaRMax = 0 * Acts::UnitConstants::mm;
0065   // maximum forward direction expressed as cot(theta)
0066   float cotThetaMax = 0;
0067   // maximum impact parameter in mm
0068   float impactMax = 0 * Acts::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   bool isInInternalUnits = false;
0086   CylindricalSpacePointGridConfig toInternalUnits() const {
0087     if (isInInternalUnits) {
0088       throw std::runtime_error(
0089           "Repeated conversion to internal units for "
0090           "CylindricalSpacePointGridConfig");
0091     }
0092 
0093     using namespace Acts::UnitLiterals;
0094     CylindricalSpacePointGridConfig config = *this;
0095     config.isInInternalUnits = true;
0096     config.minPt /= 1_MeV;
0097     config.rMin /= 1_mm;
0098     config.rMax /= 1_mm;
0099     config.zMax /= 1_mm;
0100     config.zMin /= 1_mm;
0101     config.deltaRMax /= 1_mm;
0102 
0103     for (float& val : config.zBinEdges) {
0104       val /= 1_mm;
0105     }
0106     for (float& val : config.rBinEdges) {
0107       val /= 1_mm;
0108     }
0109 
0110     if (config.phiMin < -std::numbers::pi_v<float> ||
0111         config.phiMax > std::numbers::pi_v<float>) {
0112       throw std::runtime_error(
0113           "CylindricalSpacePointGridConfig: phiMin (" +
0114           std::to_string(config.phiMin) + ") and/or phiMax (" +
0115           std::to_string(config.phiMax) +
0116           ") are outside "
0117           "the allowed phi range, defined as "
0118           "[-std::numbers::pi_v<float>, std::numbers::pi_v<float>]");
0119     }
0120     if (config.phiMin > config.phiMax) {
0121       throw std::runtime_error(
0122           "CylindricalSpacePointGridConfig: phiMin is bigger then phiMax");
0123     }
0124     if (config.rMin > config.rMax) {
0125       throw std::runtime_error(
0126           "CylindricalSpacePointGridConfig: rMin is bigger then rMax");
0127     }
0128     if (config.zMin > config.zMax) {
0129       throw std::runtime_error(
0130           "CylindricalSpacePointGridConfig: zMin is bigger than zMax");
0131     }
0132 
0133     return config;
0134   }
0135 };
0136 
0137 struct CylindricalSpacePointGridOptions {
0138   // magnetic field
0139   float bFieldInZ = 0. * Acts::UnitConstants::T;
0140   bool isInInternalUnits = false;
0141   CylindricalSpacePointGridOptions toInternalUnits() const {
0142     if (isInInternalUnits) {
0143       throw std::runtime_error(
0144           "Repeated conversion to internal units for "
0145           "CylindricalSpacePointGridOptions");
0146     }
0147     using namespace Acts::UnitLiterals;
0148     CylindricalSpacePointGridOptions options = *this;
0149     options.isInInternalUnits = true;
0150     options.bFieldInZ /= 1000_T;
0151 
0152     return options;
0153   }
0154 };
0155 
0156 /// Instructions on how to create and fill this grid specialization
0157 class CylindricalSpacePointGridCreator {
0158  public:
0159   template <typename external_spacepoint_t>
0160   static Acts::CylindricalSpacePointGrid<external_spacepoint_t> createGrid(
0161       const Acts::CylindricalSpacePointGridConfig& _config,
0162       const Acts::CylindricalSpacePointGridOptions& _options,
0163       const Acts::Logger& logger = Acts::getDummyLogger());
0164 
0165   template <typename external_spacepoint_t,
0166             typename external_spacepoint_iterator_t>
0167   static void fillGrid(
0168       const Acts::SeedFinderConfig<external_spacepoint_t>& config,
0169       const Acts::SeedFinderOptions& options,
0170       Acts::CylindricalSpacePointGrid<external_spacepoint_t>& grid,
0171       external_spacepoint_iterator_t spBegin,
0172       external_spacepoint_iterator_t spEnd,
0173       const Acts::Logger& logger = Acts::getDummyLogger());
0174 
0175   template <typename external_spacepoint_t, typename external_collection_t>
0176     requires std::ranges::range<external_collection_t> &&
0177              std::same_as<typename external_collection_t::value_type,
0178                           external_spacepoint_t>
0179   static void fillGrid(
0180       const Acts::SeedFinderConfig<external_spacepoint_t>& config,
0181       const Acts::SeedFinderOptions& options,
0182       Acts::CylindricalSpacePointGrid<external_spacepoint_t>& grid,
0183       const external_collection_t& collection,
0184       const Acts::Logger& logger = Acts::getDummyLogger());
0185 };
0186 
0187 }  // namespace Acts
0188 
0189 #include "Acts/Seeding/detail/CylindricalSpacePointGrid.ipp"