CMS 3D CMS Logo

TrackingRecHit2DSOAView.h
Go to the documentation of this file.
1 #ifndef CUDADataFormats_TrackingRecHit_interface_TrackingRecHit2DSOAView_h
2 #define CUDADataFormats_TrackingRecHit_interface_TrackingRecHit2DSOAView_h
3 
4 #include <cuda_runtime.h>
5 
11 
12 namespace pixelCPEforGPU {
13  struct ParamsOnGPU;
14 }
15 
17 public:
19  static_assert(sizeof(Status) == sizeof(uint8_t));
20 
21  using hindex_type = uint32_t; // if above is <=2^32
22 
23  using PhiBinner = cms::cuda::
24  HistoContainer<int16_t, 256, -1, 8 * sizeof(int16_t), hindex_type, pixelTopology::maxLayers>; //28 for phase2 geometry
25 
27 
28  template <typename>
31 
32  __device__ __forceinline__ uint32_t nHits() const { return m_nHits; }
33  __device__ __forceinline__ uint32_t nMaxModules() const { return m_nMaxModules; }
34 
35  __device__ __forceinline__ float& xLocal(int i) { return m_xl[i]; }
36  __device__ __forceinline__ float xLocal(int i) const { return __ldg(m_xl + i); }
37  __device__ __forceinline__ float& yLocal(int i) { return m_yl[i]; }
38  __device__ __forceinline__ float yLocal(int i) const { return __ldg(m_yl + i); }
39 
40  __device__ __forceinline__ float& xerrLocal(int i) { return m_xerr[i]; }
41  __device__ __forceinline__ float xerrLocal(int i) const { return __ldg(m_xerr + i); }
42  __device__ __forceinline__ float& yerrLocal(int i) { return m_yerr[i]; }
43  __device__ __forceinline__ float yerrLocal(int i) const { return __ldg(m_yerr + i); }
44 
45  __device__ __forceinline__ float& xGlobal(int i) { return m_xg[i]; }
46  __device__ __forceinline__ float xGlobal(int i) const { return __ldg(m_xg + i); }
47  __device__ __forceinline__ float& yGlobal(int i) { return m_yg[i]; }
48  __device__ __forceinline__ float yGlobal(int i) const { return __ldg(m_yg + i); }
49  __device__ __forceinline__ float& zGlobal(int i) { return m_zg[i]; }
50  __device__ __forceinline__ float zGlobal(int i) const { return __ldg(m_zg + i); }
51  __device__ __forceinline__ float& rGlobal(int i) { return m_rg[i]; }
52  __device__ __forceinline__ float rGlobal(int i) const { return __ldg(m_rg + i); }
53 
54  __device__ __forceinline__ int16_t& iphi(int i) { return m_iphi[i]; }
55  __device__ __forceinline__ int16_t iphi(int i) const { return __ldg(m_iphi + i); }
56 
57  __device__ __forceinline__ void setChargeAndStatus(int i, uint32_t ich, Status is) {
58  ich = std::min(ich, chargeMask());
59  uint32_t w = *reinterpret_cast<uint8_t*>(&is);
60  ich |= (w << 24);
62  }
63 
64  __device__ __forceinline__ uint32_t charge(int i) const { return __ldg(m_chargeAndStatus + i) & 0xFFFFFF; }
65 
67  uint8_t w = __ldg(m_chargeAndStatus + i) >> 24;
68  return *reinterpret_cast<Status*>(&w);
69  }
70 
71  __device__ __forceinline__ int16_t& clusterSizeX(int i) { return m_xsize[i]; }
72  __device__ __forceinline__ int16_t clusterSizeX(int i) const { return __ldg(m_xsize + i); }
73  __device__ __forceinline__ int16_t& clusterSizeY(int i) { return m_ysize[i]; }
74  __device__ __forceinline__ int16_t clusterSizeY(int i) const { return __ldg(m_ysize + i); }
75  __device__ __forceinline__ uint16_t& detectorIndex(int i) { return m_detInd[i]; }
76  __device__ __forceinline__ uint16_t detectorIndex(int i) const { return __ldg(m_detInd + i); }
77 
78  __device__ __forceinline__ pixelCPEforGPU::ParamsOnGPU const& cpeParams() const { return *m_cpeParams; }
79 
80  __device__ __forceinline__ uint32_t hitsModuleStart(int i) const { return __ldg(m_hitsModuleStart + i); }
81 
82  __device__ __forceinline__ uint32_t* hitsLayerStart() { return m_hitsLayerStart; }
83  __device__ __forceinline__ uint32_t const* hitsLayerStart() const { return m_hitsLayerStart; }
84 
87 
89  __device__ __forceinline__ AverageGeometry const& averageGeometry() const { return *m_averageGeometry; }
90 
91 private:
92  // local coord
93  float *m_xl, *m_yl;
94  float *m_xerr, *m_yerr;
95 
96  // global coord
97  float *m_xg, *m_yg, *m_zg, *m_rg;
98  int16_t* m_iphi;
99 
100  // cluster properties
101  static constexpr uint32_t chargeMask() { return (1 << 24) - 1; }
102  uint32_t* m_chargeAndStatus;
103  int16_t* m_xsize;
104  int16_t* m_ysize;
105  uint16_t* m_detInd;
106 
107  // supporting objects
108  // m_averageGeometry is corrected for beam spot, not sure where to host it otherwise
109  AverageGeometry* m_averageGeometry; // owned by TrackingRecHit2DHeterogeneous
110  pixelCPEforGPU::ParamsOnGPU const* m_cpeParams; // forwarded from setup, NOT owned
111  uint32_t const* m_hitsModuleStart; // forwarded from clusters
112 
113  uint32_t* m_hitsLayerStart;
114 
117 
118  uint32_t m_nHits;
119  uint32_t m_nMaxModules;
120 };
121 
122 #endif // CUDADataFormats_TrackingRecHit_interface_TrackingRecHit2DSOAView_h
constexpr int nMaxModules
__device__ uint32_t Status is
#define __forceinline__
Definition: cudaCompat.h:22
static constexpr uint32_t chargeMask()
constexpr uint32_t maxLayers
typename Base::index_type index_type
auto const &__restrict__ phiBinner
PhiBinner::index_type * m_phiBinnerStorage
T __ldg(T const *x)
Definition: cudaCompat.h:137
caConstants::TupleMultiplicity const CAHitNtupletGeneratorKernelsGPU::HitToTuple const cms::cuda::AtomicPairCounter GPUCACell const *__restrict__ uint32_t const *__restrict__ gpuPixelDoublets::CellNeighborsVector const gpuPixelDoublets::CellTracksVector const GPUCACell::OuterHitOfCell const int32_t nHits
pixelCPEforGPU::ParamsOnGPU const * m_cpeParams
#define __device__