14 #include <type_traits>
18 template <
typename external_spacepo
int_t>
22 : m_config(config), m_options(options) {
24 throw std::runtime_error(
25 "SeedFinderConfig not in ACTS internal units in "
26 "Cuda/Seeding/SeedFinder");
27 if (not m_options.isInInternalUnits)
28 throw std::runtime_error(
29 "SeedFinderOptions not in ACTS internal units in "
30 "Cuda/Seeding/SeedFinder");
32 throw std::runtime_error(
"Value of deltaRMaxTopSP was not initialised");
35 throw std::runtime_error(
"Value of deltaRMinTopSP was not initialised");
38 throw std::runtime_error(
"Value of deltaRMaxBottomSP was not initialised");
41 throw std::runtime_error(
"Value of deltaRMinBottomSP was not initialised");
46 template <
typename external_spacepo
int_t>
47 template <
typename sp_range_t>
48 std::vector<Seed<external_spacepoint_t>>
52 const sp_range_t& bottomSPs,
const std::size_t middleSPs,
53 const sp_range_t& topSPs)
const {
54 std::vector<Seed<external_spacepoint_t>> outputVec;
69 &seedFilterConfig.deltaInvHelixDiameter);
71 &seedFilterConfig.impactWeightFactor);
80 std::vector<Acts::InternalSpacePoint<external_spacepoint_t>*> middleSPvec;
81 std::vector<Acts::InternalSpacePoint<external_spacepoint_t>*> bottomSPvec;
82 std::vector<Acts::InternalSpacePoint<external_spacepoint_t>*> topSPvec;
90 auto& sp_collection = grid.
at(middleSPs);
91 for (
auto& sp : sp_collection) {
93 middleSPvec.push_back(sp.get());
96 for (
auto idx : bottomSPs) {
97 auto& sp_collection = grid.
at(
idx);
98 for (
auto& sp : sp_collection) {
100 bottomSPvec.push_back(sp.get());
103 for (std::size_t
idx : topSPs) {
104 auto& sp_collection = grid.
at(
idx);
105 for (
auto& sp : sp_collection) {
107 topSPvec.push_back(sp.get());
115 if (nSpM == 0 || nSpB == 0 || nSpT == 0)
123 auto fillMatrix = [](
auto& mat,
auto&
id,
auto sp) {
124 mat.set(
id, 0, sp->x());
125 mat.set(
id, 1, sp->y());
126 mat.set(
id, 2, sp->z());
127 mat.set(
id, 3, sp->radius());
128 mat.set(
id, 4, sp->varianceR());
129 mat.set(
id, 5, sp->varianceZ());
134 for (
auto sp : middleSPvec) {
135 fillMatrix(spMmat_cpu, mIdx, sp);
138 for (
auto sp : bottomSPvec) {
139 fillMatrix(spBmat_cpu, bIdx, sp);
142 for (
auto sp : topSPvec) {
143 fillMatrix(spTmat_cpu, tIdx, sp);
157 nSpBcompPerSpM_cuda.zeros();
159 nSpTcompPerSpM_cuda.zeros();
167 dim3 DS_GridSize(nSpM, 1, 1);
169 searchDoublet(DS_GridSize, DS_BlockSize, nSpM_cuda.get(), spMmat_cuda.get(),
170 nSpB_cuda.get(), spBmat_cuda.get(), nSpT_cuda.get(),
171 spTmat_cuda.get(), deltaRMin_cuda.get(), deltaRMax_cuda.get(),
172 cotThetaMax_cuda.get(), collisionRegionMin_cuda.get(),
173 collisionRegionMax_cuda.get(), nSpMcomp_cuda.get(),
174 nSpBcompPerSpMMax_cuda.get(), nSpTcompPerSpMMax_cuda.get(),
175 nSpBcompPerSpM_cuda.get(), nSpTcompPerSpM_cuda.get(),
176 McompIndex_cuda.get(), BcompIndex_cuda.get(),
177 tmpBcompIndex_cuda.get(), TcompIndex_cuda.get(),
178 tmpTcompIndex_cuda.get());
193 (*nSpMcomp_cpu.get()) * 6);
195 (*nSpMcomp_cpu.get()) * 6);
197 (*nSpMcomp_cpu.get()) * 6);
199 (*nSpMcomp_cpu.get()) * 6);
201 dim3 TC_GridSize(*nSpMcomp_cpu.get(), 1, 1);
205 TC_GridSize, TC_BlockSize, nSpM_cuda.get(), spMmat_cuda.get(),
206 McompIndex_cuda.get(), nSpB_cuda.get(), spBmat_cuda.get(),
207 nSpBcompPerSpMMax_cuda.get(), BcompIndex_cuda.get(), nSpT_cuda.get(),
208 spTmat_cuda.get(), nSpTcompPerSpMMax_cuda.get(), TcompIndex_cuda.get(),
209 spMcompMat_cuda.get(), spBcompMatPerSpM_cuda.get(),
210 circBcompMatPerSpM_cuda.get(), spTcompMatPerSpM_cuda.get(),
211 circTcompMatPerSpM_cuda.get());
217 const int nTrplPerSpMLimit =
223 &nTrplPerSpBLimit_cuda);
226 nTrplPerSpM_cuda.zeros();
228 *nSpMcomp_cpu.get());
230 nTrplPerSpM_cpu.
zeros();
233 cudaStream_t cuStream;
234 ACTS_CUDA_ERROR_CHECK(cudaStreamCreate(&cuStream));
236 for (
int i_m = 0; i_m <= *nSpMcomp_cpu.get(); i_m++) {
237 cudaStreamSynchronize(cuStream);
240 if (i_m < *nSpMcomp_cpu.get()) {
241 int mIndex = *McompIndex_cpu.
get(i_m);
242 int* nSpBcompPerSpM = nSpBcompPerSpM_cpu.
get(mIndex);
243 int* nSpTcompPerSpM = nSpTcompPerSpM_cpu.
get(mIndex);
245 dim3 TS_GridSize(*nSpBcompPerSpM, 1, 1);
250 TS_GridSize, TS_BlockSize, nSpTcompPerSpM_cpu.
get(mIndex),
251 nSpTcompPerSpM_cuda.get(mIndex), nSpMcomp_cuda.get(),
252 spMcompMat_cuda.get(i_m, 0), nSpBcompPerSpMMax_cuda.get(),
253 BcompIndex_cuda.get(0, i_m), circBcompMatPerSpM_cuda.get(0, 6 * i_m),
254 nSpTcompPerSpMMax_cuda.get(), TcompIndex_cuda.get(0, i_m),
255 spTcompMatPerSpM_cuda.get(0, 6 * i_m),
256 circTcompMatPerSpM_cuda.get(0, 6 * i_m),
258 maxScatteringAngle2_cuda.get(), sigmaScattering_cuda.get(),
259 minHelixDiameter2_cuda.get(), pT2perRadius_cuda.get(),
260 impactMax_cuda.get(), nTrplPerSpMLimit_cuda.get(),
261 nTrplPerSpBLimit_cpu.
get(), nTrplPerSpBLimit_cuda.get(),
262 deltaInvHelixDiameter_cuda.get(), impactWeightFactor_cuda.get(),
263 filterDeltaRMin_cuda.get(), compatSeedWeight_cuda.get(),
264 compatSeedLimit_cpu.
get(), compatSeedLimit_cuda.get(),
266 nTrplPerSpM_cuda.get(i_m), TripletsPerSpM_cuda.get(0, i_m),
268 nTrplPerSpM_cpu.copyD2H(nTrplPerSpM_cuda.get(i_m), 1, i_m, &cuStream);
270 TripletsPerSpM_cpu.copyD2H(TripletsPerSpM_cuda.get(0, i_m),
271 nTrplPerSpMLimit, nTrplPerSpMLimit * i_m,
281 for (
int i = 0;
i < *nTrplPerSpM_cpu.get(i_m - 1);
i++) {
282 auto& triplet = *TripletsPerSpM_cpu.get(
i, i_m - 1);
283 int mIndex = *McompIndex_cpu.
get(i_m - 1);
284 int bIndex = triplet.bIndex;
285 int tIndex = triplet.tIndex;
287 auto& bottomSP = *bottomSPvec[bIndex];
288 auto& middleSP = *middleSPvec[mIndex];
289 auto& topSP = *topSPvec[tIndex];
290 if (m_experimentCuts !=
nullptr) {
293 m_experimentCuts->seedWeight(bottomSP, middleSP, topSP);
295 if (!m_experimentCuts->singleSeedCut(triplet.weight, bottomSP,
304 candidates.emplace_back(bottomSP, middleSP, topSP, triplet.weight, Zob,
308 std::sort(candidates.begin(), candidates.end(),
310 external_spacepoint_t>>::descendingByQuality);
311 std::size_t numQualitySeeds = 0;
314 std::back_inserter(outputVec));
317 ACTS_CUDA_ERROR_CHECK(cudaStreamDestroy(cuStream));