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::HistoContainer<int16_t, 128, -1, 8 * sizeof(int16_t), hindex_type, 10>;
24 
26 
27  template <typename>
30 
31  __device__ __forceinline__ uint32_t nHits() const { return m_nHits; }
32 
33  __device__ __forceinline__ float& xLocal(int i) { return m_xl[i]; }
34  __device__ __forceinline__ float xLocal(int i) const { return __ldg(m_xl + i); }
35  __device__ __forceinline__ float& yLocal(int i) { return m_yl[i]; }
36  __device__ __forceinline__ float yLocal(int i) const { return __ldg(m_yl + i); }
37 
38  __device__ __forceinline__ float& xerrLocal(int i) { return m_xerr[i]; }
39  __device__ __forceinline__ float xerrLocal(int i) const { return __ldg(m_xerr + i); }
40  __device__ __forceinline__ float& yerrLocal(int i) { return m_yerr[i]; }
41  __device__ __forceinline__ float yerrLocal(int i) const { return __ldg(m_yerr + i); }
42 
43  __device__ __forceinline__ float& xGlobal(int i) { return m_xg[i]; }
44  __device__ __forceinline__ float xGlobal(int i) const { return __ldg(m_xg + i); }
45  __device__ __forceinline__ float& yGlobal(int i) { return m_yg[i]; }
46  __device__ __forceinline__ float yGlobal(int i) const { return __ldg(m_yg + i); }
47  __device__ __forceinline__ float& zGlobal(int i) { return m_zg[i]; }
48  __device__ __forceinline__ float zGlobal(int i) const { return __ldg(m_zg + i); }
49  __device__ __forceinline__ float& rGlobal(int i) { return m_rg[i]; }
50  __device__ __forceinline__ float rGlobal(int i) const { return __ldg(m_rg + i); }
51 
52  __device__ __forceinline__ int16_t& iphi(int i) { return m_iphi[i]; }
53  __device__ __forceinline__ int16_t iphi(int i) const { return __ldg(m_iphi + i); }
54 
55  __device__ __forceinline__ void setChargeAndStatus(int i, uint32_t ich, Status is) {
56  ich = std::min(ich, chargeMask());
57  uint32_t w = *reinterpret_cast<uint8_t*>(&is);
58  ich |= (w << 24);
60  }
61 
62  __device__ __forceinline__ uint32_t charge(int i) const { return __ldg(m_chargeAndStatus + i) & 0xFFFFFF; }
63 
65  uint8_t w = __ldg(m_chargeAndStatus + i) >> 24;
66  return *reinterpret_cast<Status*>(&w);
67  }
68 
69  __device__ __forceinline__ int16_t& clusterSizeX(int i) { return m_xsize[i]; }
70  __device__ __forceinline__ int16_t clusterSizeX(int i) const { return __ldg(m_xsize + i); }
71  __device__ __forceinline__ int16_t& clusterSizeY(int i) { return m_ysize[i]; }
72  __device__ __forceinline__ int16_t clusterSizeY(int i) const { return __ldg(m_ysize + i); }
73  __device__ __forceinline__ uint16_t& detectorIndex(int i) { return m_detInd[i]; }
74  __device__ __forceinline__ uint16_t detectorIndex(int i) const { return __ldg(m_detInd + i); }
75 
76  __device__ __forceinline__ pixelCPEforGPU::ParamsOnGPU const& cpeParams() const { return *m_cpeParams; }
77 
78  __device__ __forceinline__ uint32_t hitsModuleStart(int i) const { return __ldg(m_hitsModuleStart + i); }
79 
80  __device__ __forceinline__ uint32_t* hitsLayerStart() { return m_hitsLayerStart; }
81  __device__ __forceinline__ uint32_t const* hitsLayerStart() const { return m_hitsLayerStart; }
82 
85 
87  __device__ __forceinline__ AverageGeometry const& averageGeometry() const { return *m_averageGeometry; }
88 
89 private:
90  // local coord
91  float *m_xl, *m_yl;
92  float *m_xerr, *m_yerr;
93 
94  // global coord
95  float *m_xg, *m_yg, *m_zg, *m_rg;
96  int16_t* m_iphi;
97 
98  // cluster properties
99  static constexpr uint32_t chargeMask() { return (1 << 24) - 1; }
100  uint32_t* m_chargeAndStatus;
101  int16_t* m_xsize;
102  int16_t* m_ysize;
103  uint16_t* m_detInd;
104 
105  // supporting objects
106  // m_averageGeometry is corrected for beam spot, not sure where to host it otherwise
107  AverageGeometry* m_averageGeometry; // owned by TrackingRecHit2DHeterogeneous
108  pixelCPEforGPU::ParamsOnGPU const* m_cpeParams; // forwarded from setup, NOT owned
109  uint32_t const* m_hitsModuleStart; // forwarded from clusters
110 
111  uint32_t* m_hitsLayerStart;
112 
115 
116  uint32_t m_nHits;
117 };
118 
119 #endif // CUDADataFormats_TrackingRecHit_interface_TrackingRecHit2DSOAView_h
TrackingRecHit2DSOAView::m_iphi
int16_t * m_iphi
Definition: TrackingRecHit2DSOAView.h:96
TrackingRecHit2DSOAView::m_yg
float * m_yg
Definition: TrackingRecHit2DSOAView.h:95
TrackingRecHit2DSOAView::m_hitsLayerStart
uint32_t * m_hitsLayerStart
Definition: TrackingRecHit2DSOAView.h:111
TrackingRecHit2DSOAView::m_xerr
float * m_xerr
Definition: TrackingRecHit2DSOAView.h:92
mps_fire.i
i
Definition: mps_fire.py:428
mps_update.status
status
Definition: mps_update.py:68
SiPixelHitStatus
Definition: SiPixelHitStatus.h:7
min
T min(T a, T b)
Definition: MathUtil.h:58
TrackingRecHit2DHeterogeneous
Definition: TrackingRecHit2DHeterogeneous.h:8
TrackingRecHit2DSOAView::ich
__device__ uint32_t ich
Definition: TrackingRecHit2DSOAView.h:55
TrackingRecHit2DSOAView::m_xl
float * m_xl
Definition: TrackingRecHit2DSOAView.h:91
TrackingRecHit2DSOAView::hindex_type
uint32_t hindex_type
Definition: TrackingRecHit2DSOAView.h:21
TrackingRecHit2DSOAView::m_nHits
uint32_t m_nHits
Definition: TrackingRecHit2DSOAView.h:116
pixelCPEforGPU
Definition: TrackingRecHit2DSOAView.h:12
TrackingRecHit2DSOAView
Definition: TrackingRecHit2DSOAView.h:16
LEDCalibrationChannels.iphi
iphi
Definition: LEDCalibrationChannels.py:64
cms::cuda::HistoContainer::index_type
typename Base::index_type index_type
Definition: HistoContainer.h:106
nHits
const caConstants::TupleMultiplicity *__restrict__ const HitsOnGPU *__restrict__ double *__restrict__ float *__restrict__ double *__restrict__ uint32_t nHits
Definition: BrokenLineFitOnGPU.h:27
TrackingRecHit2DSOAView::m_ysize
int16_t * m_ysize
Definition: TrackingRecHit2DSOAView.h:102
ALCARECOTkAlJpsiMuMu_cff.charge
charge
Definition: ALCARECOTkAlJpsiMuMu_cff.py:47
TrackingRecHit2DSOAView::m_chargeAndStatus
uint32_t * m_chargeAndStatus
Definition: TrackingRecHit2DSOAView.h:100
TrackingRecHit2DSOAView::m_averageGeometry
AverageGeometry * m_averageGeometry
Definition: TrackingRecHit2DSOAView.h:107
TrackingRecHit2DSOAView::w
uint32_t w
Definition: TrackingRecHit2DSOAView.h:57
gpuClusteringConstants.h
TrackingRecHit2DSOAView::m_cpeParams
pixelCPEforGPU::ParamsOnGPU const * m_cpeParams
Definition: TrackingRecHit2DSOAView.h:108
TrackingRecHit2DSOAView::m_yerr
float * m_yerr
Definition: TrackingRecHit2DSOAView.h:92
__device__
#define __device__
Definition: SiPixelGainForHLTonGPU.h:15
gpuPixelDoublets::phiBinner
auto const &__restrict__ phiBinner
Definition: gpuPixelDoubletsAlgos.h:55
__forceinline__
#define __forceinline__
Definition: cudaCompat.h:22
phase1PixelTopology::AverageGeometry
Definition: phase1PixelTopology.h:161
TrackingRecHit2DSOAView::m_phiBinner
PhiBinner * m_phiBinner
Definition: TrackingRecHit2DSOAView.h:113
HistoContainer.h
pixelCPEforGPU::ParamsOnGPU
Definition: pixelCPEforGPU.h:60
SiPixelHitStatus.h
TrackingRecHit2DSOAView::m_chargeAndStatus
m_chargeAndStatus[i]
Definition: TrackingRecHit2DSOAView.h:59
TrackingRecHit2DReduced
Definition: TrackingRecHit2DReduced.h:8
TrackingRecHit2DSOAView::m_yl
float * m_yl
Definition: TrackingRecHit2DSOAView.h:91
TrackingRecHit2DSOAView::m_phiBinnerStorage
PhiBinner::index_type * m_phiBinnerStorage
Definition: TrackingRecHit2DSOAView.h:114
cudaCompat.h
TrackingRecHit2DSOAView::chargeMask
static constexpr uint32_t chargeMask()
Definition: TrackingRecHit2DSOAView.h:99
TrackingRecHit2DSOAView::m_xg
float * m_xg
Definition: TrackingRecHit2DSOAView.h:95
TrackingRecHit2DSOAView::m_xsize
int16_t * m_xsize
Definition: TrackingRecHit2DSOAView.h:101
cms::cuda::HistoContainer
Definition: HistoContainer.h:101
cms::cudacompat::__ldg
T __ldg(T const *x)
Definition: cudaCompat.h:113
TrackingRecHit2DSOAView::is
__device__ uint32_t Status is
Definition: TrackingRecHit2DSOAView.h:55
TrackingRecHit2DSOAView::m_detInd
uint16_t * m_detInd
Definition: TrackingRecHit2DSOAView.h:103
phase1PixelTopology.h
TrackingRecHit2DSOAView::m_hitsModuleStart
uint32_t const * m_hitsModuleStart
Definition: TrackingRecHit2DSOAView.h:109
TrackingRecHit2DSOAView::m_rg
float * m_rg
Definition: TrackingRecHit2DSOAView.h:95
TrackingRecHit2DSOAView::m_zg
float * m_zg
Definition: TrackingRecHit2DSOAView.h:95