EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Seedfinder.ipp
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file Seedfinder.ipp
1 // This file is part of the Acts project.
2 //
3 // Copyright (C) 2020 CERN for the benefit of the Acts project
4 //
5 // This Source Code Form is subject to the terms of the Mozilla Public
6 // License, v. 2.0. If a copy of the MPL was not distributed with this
7 // file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 
9 // System include(s)
10 #include <algorithm>
11 #include <cmath>
12 #include <utility>
13 
14 // SYCL plugin include(s)
17 
18 namespace Acts::Sycl {
19 template <typename external_spacepoint_t>
23  Acts::Sycl::QueueWrapper wrappedQueue)
24  : m_config(config),
25  m_deviceCuts(cuts),
26  m_wrappedQueue(std::move(wrappedQueue)) {
27  // init m_config
28  m_config.highland = 13.6f * std::sqrt(m_config.radLengthPerSeed) *
29  (1 + 0.038f * std::log(m_config.radLengthPerSeed));
30  float maxScatteringAngle = m_config.highland / m_config.minPt;
31  m_config.maxScatteringAngle2 = maxScatteringAngle * maxScatteringAngle;
34  std::pow(m_config.minPt * 2 / m_config.pTPerHelixRadius, 2);
37 
38  auto seedFilterConfig = m_config.seedFilter->getSeedFilterConfig();
39 
40  // init m_deviceConfig
51  seedFilterConfig.deltaInvHelixDiameter,
52  seedFilterConfig.impactWeightFactor,
53  seedFilterConfig.deltaRMin,
54  seedFilterConfig.compatSeedWeight,
56  seedFilterConfig.compatSeedLimit,
57  };
58 }
59 
60 template <typename external_spacepoint_t>
61 template <typename sp_range_t>
62 std::vector<Acts::Seed<external_spacepoint_t>>
64  sp_range_t bottomSPs, sp_range_t middleSPs, sp_range_t topSPs) const {
65  std::vector<Seed<external_spacepoint_t>> outputVec;
66 
67  // As a first step, we create Arrays of Structures (AoS)
68  // that are easily comprehensible by the GPU. This allows us
69  // less memory access operations than with simple (float) arrays.
70 
71  std::vector<detail::DeviceSpacePoint> deviceBottomSPs;
72  std::vector<detail::DeviceSpacePoint> deviceMiddleSPs;
73  std::vector<detail::DeviceSpacePoint> deviceTopSPs;
74 
75  std::vector<const Acts::InternalSpacePoint<external_spacepoint_t>*>
76  bottomSPvec;
77  std::vector<const Acts::InternalSpacePoint<external_spacepoint_t>*>
78  middleSPvec;
79  std::vector<const Acts::InternalSpacePoint<external_spacepoint_t>*> topSPvec;
80 
81  for (auto SP : bottomSPs) {
82  bottomSPvec.push_back(SP);
83  deviceBottomSPs.push_back(
84  detail::DeviceSpacePoint{SP->x(), SP->y(), SP->z(), SP->radius(),
85  SP->varianceR(), SP->varianceZ()});
86  }
87 
88  for (auto SP : middleSPs) {
89  middleSPvec.push_back(SP);
90  deviceMiddleSPs.push_back(
91  detail::DeviceSpacePoint{SP->x(), SP->y(), SP->z(), SP->radius(),
92  SP->varianceR(), SP->varianceZ()});
93  }
94 
95  for (auto SP : topSPs) {
96  topSPvec.push_back(SP);
97  deviceTopSPs.push_back(
98  detail::DeviceSpacePoint{SP->x(), SP->y(), SP->z(), SP->radius(),
99  SP->varianceR(), SP->varianceZ()});
100  }
101 
102  std::vector<std::vector<detail::SeedData>> seeds;
103 
104  // Call the SYCL seeding algorithm
105  createSeedsForGroupSycl(m_wrappedQueue, m_deviceConfig, m_deviceCuts,
106  deviceBottomSPs, deviceMiddleSPs, deviceTopSPs,
107  seeds);
108 
109  // Iterate through seeds returned by the SYCL algorithm and perform the last
110  // step of filtering for fixed middle SP.
111  std::vector<std::pair<
112  float, std::unique_ptr<const InternalSeed<external_spacepoint_t>>>>
113  seedsPerSPM;
114  for (size_t mi = 0; mi < seeds.size(); ++mi) {
115  seedsPerSPM.clear();
116  for (size_t j = 0; j < seeds[mi].size(); ++j) {
117  auto& bottomSP = *(bottomSPvec[seeds[mi][j].bottom]);
118  auto& middleSP = *(middleSPvec[mi]);
119  auto& topSP = *(topSPvec[seeds[mi][j].top]);
120  float weight = seeds[mi][j].weight;
121 
122  seedsPerSPM.emplace_back(std::make_pair(
123  weight, std::make_unique<const InternalSeed<external_spacepoint_t>>(
124  bottomSP, middleSP, topSP, 0)));
125  }
126  m_config.seedFilter->filterSeeds_1SpFixed(seedsPerSPM, outputVec);
127  }
128  return outputVec;
129 }
130 } // namespace Acts::Sycl