CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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 float(gain) * gainPrecision_ + minGain_; }
60  constexpr float decodePed(unsigned int ped) const { return float(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
constexpr float decodeGain(unsigned int gain) const
#define __host__
DecodingStructure * v_pedestals_
std::pair< uint32_t, uint32_t > Range
assert(be >=bs)
const uint16_t range(const Frame &aFrame)
constexpr float decodePed(unsigned int ped) const
constexpr uint16_t maxNumModules
std::pair< float, float > getPedAndGain(uint32_t moduleInd, int col, int row, bool &isDeadColumn, bool &isNoisyColumn) const
std::pair< Range, int > rangeAndCols_[gpuClustering::maxNumModules]
int col
Definition: cuy.py:1009
#define __device__