CMS 3D CMS Logo

SiPixelGainForHLTonGPU.h
Go to the documentation of this file.
1 #ifndef CondFormats_SiPixelObjects_interface_SiPixelGainForHLTonGPU_h
2 #define CondFormats_SiPixelObjects_interface_SiPixelGainForHLTonGPU_h
3 
4 #include <cstdint>
5 #include <cstdio>
6 #include <tuple>
7 
8 // including <cuda_runtime.h> would pull in the dependency on all of CUDA;
9 // instead, just define away the CUDA specific attributes to keep GCC happy.
10 #ifndef __CUDACC__
11 #ifndef __host__
12 #define __host__
13 #endif // __host__
14 #ifndef __device__
15 #define __device__
16 #endif // __device__
17 #endif // __CUDACC__
18 
21 
23  uint8_t gain;
24  uint8_t ped;
25 };
26 
27 // copy of SiPixelGainCalibrationForHLT
29 public:
31 
32  using Range = std::pair<uint32_t, uint32_t>;
33 
34  inline __host__ __device__ std::pair<float, float> getPedAndGain(
35  uint32_t moduleInd, int col, int row, bool& isDeadColumn, bool& isNoisyColumn) const {
36  auto range = rangeAndCols_[moduleInd].first;
37  auto nCols = rangeAndCols_[moduleInd].second;
38 
39  // determine what averaged data block we are in (there should be 1 or 2 of these depending on if plaquette is 1 by X or 2 by X
40  unsigned int lengthOfColumnData = (range.second - range.first) / nCols;
41  unsigned int lengthOfAveragedDataInEachColumn = 2; // we always only have two values per column averaged block
42  unsigned int numberOfDataBlocksToSkip = row / numberOfRowsAveragedOver_;
43 
44  auto offset = range.first + col * lengthOfColumnData + lengthOfAveragedDataInEachColumn * numberOfDataBlocksToSkip;
45 
46  assert(offset < range.second);
47  assert(offset < 3088384);
48  assert(0 == offset % 2);
49 
50  DecodingStructure const* __restrict__ lp = v_pedestals_;
51  auto s = lp[offset / 2];
52 
53  isDeadColumn = (s.ped & 0xFF) == deadFlag_;
54  isNoisyColumn = (s.ped & 0xFF) == noisyFlag_;
55 
56  return std::make_pair(decodePed(s.ped & 0xFF), decodeGain(s.gain & 0xFF));
57  }
58 
59  constexpr float decodeGain(unsigned int gain) const { return gain * gainPrecision_ + minGain_; }
60  constexpr float decodePed(unsigned int ped) const { return ped * pedPrecision_ + minPed_; }
61 
64 
67 
68  unsigned int numberOfRowsAveragedOver_; // this is 80!!!!
69  unsigned int nBinsToUseForEncoding_;
70  unsigned int deadFlag_;
71  unsigned int noisyFlag_;
72 };
73 
74 #endif // CondFormats_SiPixelObjects_interface_SiPixelGainForHLTonGPU_h
FastTimerService_cff.range
range
Definition: FastTimerService_cff.py:34
SiPixelGainForHLTonGPU
Definition: SiPixelGainForHLTonGPU.h:28
SiPixelGainForHLTonGPU::numberOfRowsAveragedOver_
unsigned int numberOfRowsAveragedOver_
Definition: SiPixelGainForHLTonGPU.h:68
SiPixelGainForHLTonGPU::getPedAndGain
std::pair< float, float > getPedAndGain(uint32_t moduleInd, int col, int row, bool &isDeadColumn, bool &isNoisyColumn) const
Definition: SiPixelGainForHLTonGPU.h:34
cuy.col
col
Definition: cuy.py:1010
cms::cuda::assert
assert(be >=bs)
SiPixelGainForHLTonGPU::maxPed_
float maxPed_
Definition: SiPixelGainForHLTonGPU.h:65
SiPixelGainForHLTonGPU::rangeAndCols_
std::pair< Range, int > rangeAndCols_[gpuClustering::maxNumModules]
Definition: SiPixelGainForHLTonGPU.h:63
SiPixelGainForHLTonGPU_DecodingStructure::ped
uint8_t ped
Definition: SiPixelGainForHLTonGPU.h:24
SiPixelGainForHLTonGPU::minPed_
float minPed_
Definition: SiPixelGainForHLTonGPU.h:65
alignCSCRings.s
s
Definition: alignCSCRings.py:92
SiPixelGainForHLTonGPU_DecodingStructure
Definition: SiPixelGainForHLTonGPU.h:22
SiPixelGainForHLTonGPU::decodeGain
constexpr float decodeGain(unsigned int gain) const
Definition: SiPixelGainForHLTonGPU.h:59
gpuClustering::maxNumModules
constexpr uint16_t maxNumModules
Definition: gpuClusteringConstants.h:29
SiPixelGainForHLTonGPU::maxGain_
float maxGain_
Definition: SiPixelGainForHLTonGPU.h:65
SiPixelGainForHLTonGPU::nBinsToUseForEncoding_
unsigned int nBinsToUseForEncoding_
Definition: SiPixelGainForHLTonGPU.h:69
SiPixelGainForHLTonGPU::Range
std::pair< uint32_t, uint32_t > Range
Definition: SiPixelGainForHLTonGPU.h:32
SiPixelGainForHLTonGPU::noisyFlag_
unsigned int noisyFlag_
Definition: SiPixelGainForHLTonGPU.h:71
gpuClusteringConstants.h
__device__
#define __device__
Definition: SiPixelGainForHLTonGPU.h:15
SiPixelGainForHLTonGPU::v_pedestals_
DecodingStructure * v_pedestals_
Definition: SiPixelGainForHLTonGPU.h:62
SiPixelGainForHLTonGPU::gainPrecision_
float gainPrecision_
Definition: SiPixelGainForHLTonGPU.h:66
SiPixelGainForHLTonGPU::pedPrecision_
float pedPrecision_
Definition: SiPixelGainForHLTonGPU.h:66
PedestalClient_cfi.gain
gain
Definition: PedestalClient_cfi.py:37
SiPixelGainForHLTonGPU::decodePed
constexpr float decodePed(unsigned int ped) const
Definition: SiPixelGainForHLTonGPU.h:60
SiPixelGainForHLTonGPU::minGain_
float minGain_
Definition: SiPixelGainForHLTonGPU.h:65
SiPixelGainForHLTonGPU::deadFlag_
unsigned int deadFlag_
Definition: SiPixelGainForHLTonGPU.h:70
SiPixelGainForHLTonGPU_DecodingStructure::gain
uint8_t gain
Definition: SiPixelGainForHLTonGPU.h:23
cuda_assert.h
hltrates_dqm_sourceclient-live_cfg.offset
offset
Definition: hltrates_dqm_sourceclient-live_cfg.py:82
__host__
#define __host__
Definition: SiPixelGainForHLTonGPU.h:12