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  // 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
39  unsigned int lengthOfColumnData = (range.second - range.first) / nCols;
40  unsigned int lengthOfAveragedDataInEachColumn = 2; // we always only have two values per column averaged block
41  unsigned int numberOfDataBlocksToSkip = row / numberOfRowsAveragedOver_;
42 
43  auto offset = range.first + col * lengthOfColumnData + lengthOfAveragedDataInEachColumn * numberOfDataBlocksToSkip;
44 
45  assert(offset < range.second);
46  assert(offset < 3088384);
47  assert(0 == offset % 2);
48 
49  DecodingStructure const* __restrict__ lp = v_pedestals_;
50  auto s = lp[offset / 2];
51 
52  isDeadColumn = (s.ped & 0xFF) == deadFlag_;
53  isNoisyColumn = (s.ped & 0xFF) == noisyFlag_;
54 
55  return std::make_pair(decodePed(s.ped & 0xFF), decodeGain(s.gain & 0xFF));
56  }
57 
58  constexpr float decodeGain(unsigned int gain) const { return float(gain) * gainPrecision_ + minGain_; }
59  constexpr float decodePed(unsigned int ped) const { return float(ped) * pedPrecision_ + minPed_; }
60 
63 
66 
67  unsigned int numberOfRowsAveragedOver_; // this is 80!!!!
68  unsigned int nBinsToUseForEncoding_;
69  unsigned int deadFlag_;
70  unsigned int noisyFlag_;
71 };
72 
73 #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
constexpr uint32_t numberOfModules
assert(be >=bs)
const uint16_t range(const Frame &aFrame)
std::pair< Range, int > rangeAndCols_[phase1PixelTopology::numberOfModules]
constexpr float decodePed(unsigned int ped) const
std::pair< float, float > getPedAndGain(uint32_t moduleInd, int col, int row, bool &isDeadColumn, bool &isNoisyColumn) const
int col
Definition: cuy.py:1009
#define __device__