CMS 3D CMS Logo

gpuFishbone.h
Go to the documentation of this file.
1 #ifndef RecoPixelVertexing_PixelTriplets_plugins_gpuFishbone_h
2 #define RecoPixelVertexing_PixelTriplets_plugins_gpuFishbone_h
3 
4 #include <algorithm>
5 #include <cmath>
6 #include <cstdint>
7 #include <cstdio>
8 #include <limits>
9 
14 
15 #include "GPUCACell.h"
16 
17 namespace gpuPixelDoublets {
18 
19  // __device__
20  // __forceinline__
21  __global__ void fishbone(GPUCACell::Hits const* __restrict__ hhp,
23  uint32_t const* __restrict__ nCells,
24  GPUCACell::OuterHitOfCell const* __restrict__ isOuterHitOfCell,
25  uint32_t nHits,
26  bool checkTrack) {
28 
29  auto const& hh = *hhp;
30 
31  // x run faster...
32  auto firstY = threadIdx.y + blockIdx.y * blockDim.y;
33  auto firstX = threadIdx.x;
34 
36  uint16_t d[maxCellsPerHit]; // uint8_t l[maxCellsPerHit];
37  uint32_t cc[maxCellsPerHit];
38 
39  for (int idy = firstY, nt = nHits; idy < nt; idy += gridDim.y * blockDim.y) {
40  auto const& vc = isOuterHitOfCell[idy];
41  auto size = vc.size();
42  if (size < 2)
43  continue;
44  // if alligned kill one of the two.
45  // in principle one could try to relax the cut (only in r-z?) for jumping-doublets
46  auto const& c0 = cells[vc[0]];
47  auto xo = c0.outer_x(hh);
48  auto yo = c0.outer_y(hh);
49  auto zo = c0.outer_z(hh);
50  auto sg = 0;
51  for (int32_t ic = 0; ic < size; ++ic) {
52  auto& ci = cells[vc[ic]];
53  if (ci.unused())
54  continue; // for triplets equivalent to next
55  if (checkTrack && ci.tracks().empty())
56  continue;
57  cc[sg] = vc[ic];
58  d[sg] = ci.inner_detIndex(hh);
59  x[sg] = ci.inner_x(hh) - xo;
60  y[sg] = ci.inner_y(hh) - yo;
61  z[sg] = ci.inner_z(hh) - zo;
62  n[sg] = x[sg] * x[sg] + y[sg] * y[sg] + z[sg] * z[sg];
63  ++sg;
64  }
65  if (sg < 2)
66  continue;
67  // here we parallelize
68  for (int32_t ic = firstX; ic < sg - 1; ic += blockDim.x) {
69  auto& ci = cells[cc[ic]];
70  for (auto jc = ic + 1; jc < sg; ++jc) {
71  auto& cj = cells[cc[jc]];
72  // must be different detectors (in the same layer)
73  // if (d[ic]==d[jc]) continue;
74  // || l[ic]!=l[jc]) continue;
75  auto cos12 = x[ic] * x[jc] + y[ic] * y[jc] + z[ic] * z[jc];
76  if (d[ic] != d[jc] && cos12 * cos12 >= 0.99999f * n[ic] * n[jc]) {
77  // alligned: kill farthest (prefer consecutive layers)
78  if (n[ic] > n[jc]) {
79  ci.kill();
80  break;
81  } else {
82  cj.kill();
83  }
84  }
85  } //cj
86  } // ci
87  } // hits
88  }
89 } // namespace gpuPixelDoublets
90 
91 #endif // RecoPixelVertexing_PixelTriplets_plugins_gpuFishbone_h
dqmiodumpmetadata.n
n
Definition: dqmiodumpmetadata.py:28
f
double f[11][100]
Definition: MuScleFitUtils.cc:78
nt
int nt
Definition: AMPTWrapper.h:42
gpuPixelDoublets::idy
auto idy
Definition: gpuPixelDoubletsAlgos.h:78
GPUCACell::maxCellsPerHit
static constexpr auto maxCellsPerHit
Definition: GPUCACell.h:24
caConstants::maxCellsPerHit
constexpr uint32_t maxCellsPerHit
Definition: CAConstants.h:37
TrackingRecHit2DSOAView
Definition: TrackingRecHit2DSOAView.h:15
gpuPixelDoublets::cells
__device__ uint32_t GPUCACell * cells
Definition: gpuPixelDoubletsAlgos.h:26
__global__
#define __global__
Definition: cudaCompat.h:19
cc
gpuPixelDoublets::hh
__device__ uint32_t GPUCACell uint32_t CellNeighborsVector CellTracksVector TrackingRecHit2DSOAView const &__restrict__ hh
Definition: gpuPixelDoubletsAlgos.h:26
nHits
const caConstants::TupleMultiplicity *__restrict__ const HitsOnGPU *__restrict__ double *__restrict__ float *__restrict__ double *__restrict__ uint32_t nHits
Definition: BrokenLineFitOnGPU.h:27
gpuPixelDoublets::nCells
uint32_t * nCells
Definition: gpuPixelDoublets.h:99
VecArray.h
cms::cudacompat::gridDim
const dim3 gridDim
Definition: cudaCompat.h:33
approx_atan2.h
cms::cudacompat::blockDim
const dim3 blockDim
Definition: cudaCompat.h:30
gpuPixelDoublets
Definition: gpuFishbone.h:17
cms::cuda::VecArray
Definition: VecArray.h:14
cms::cudacompat::threadIdx
const dim3 threadIdx
Definition: cudaCompat.h:29
GPUCACell.h
gpuPixelDoublets::isOuterHitOfCell
uint32_t CellNeighborsVector CellTracksVector TrackingRecHit2DSOAView const *__restrict__ GPUCACell::OuterHitOfCell * isOuterHitOfCell
Definition: gpuPixelDoublets.h:99
fftjetpileupestimator_calo_uncalib_cfi.c0
c0
Definition: fftjetpileupestimator_calo_uncalib_cfi.py:8
ztail.d
d
Definition: ztail.py:151
GPUCACell
Definition: GPUCACell.h:20
cuda_assert.h
phase1PixelTopology.h
gpuPixelDoublets::hhp
uint32_t CellNeighborsVector CellTracksVector TrackingRecHit2DSOAView const *__restrict__ hhp
Definition: gpuPixelDoublets.h:99
findQualityFiles.size
size
Write out results.
Definition: findQualityFiles.py:443
cms::cudacompat::blockIdx
const dim3 blockIdx
Definition: cudaCompat.h:32