CMS 3D CMS Logo

PixelChannelIdentifier.h
Go to the documentation of this file.
1 #ifndef DataFormats_SiPixelDetId_interface_PixelChannelIdentifier_h
2 #define DataFormats_SiPixelDetId_interface_PixelChannelIdentifier_h
3 
4 #include <utility>
5 #include <cstdint>
6 
12  class Packing {
13  public:
14  using PackedDigiType = uint32_t;
15 
16  // Constructor: pre-computes masks and shifts from field widths
17  constexpr Packing(unsigned int row_w, unsigned int column_w, unsigned int flag_w, unsigned int adc_w)
18  : row_width(row_w),
19  column_width(column_w),
20  adc_width(adc_w),
21  row_shift(0),
22  column_shift(row_shift + row_w),
23  flag_shift(column_shift + column_w),
24  adc_shift(flag_shift + flag_w),
25  row_mask(~(~0U << row_w)),
26  column_mask(~(~0U << column_w)),
27  flag_mask(~(~0U << flag_w)),
28  adc_mask(~(~0U << adc_w)),
29  rowcol_mask(~(~0U << (column_w + row_w))),
32  max_adc(adc_mask) {}
33 
34  const uint32_t row_width;
35  const uint32_t column_width;
36  const uint32_t adc_width;
37 
38  const uint32_t row_shift;
39  const uint32_t column_shift;
40  const uint32_t flag_shift;
41  const uint32_t adc_shift;
42 
48 
49  const int max_row;
50  const int max_column;
51  const int max_adc;
52  };
53 } // namespace pixelchannelidentifierimpl
54 
56 public:
57  typedef unsigned int PackedDigiType;
58  typedef unsigned int ChannelType;
59 
60  static std::pair<int, int> channelToPixel(int ch) {
61  int row = (ch >> thePacking.column_width) & thePacking.row_mask;
62  int col = ch & thePacking.column_mask;
63  return std::pair<int, int>(row, col);
64  }
65 
66  static int pixelToChannel(int row, int col) { return (row << thePacking.column_width) | col; }
67 
69 
70 public:
71  constexpr static Packing packing() { return Packing(8, 9, 4, 11); }
72 
73  constexpr static Packing thePacking = {11, 10, 1, 10};
74 };
75 
76 #endif // DataFormats_SiPixelDetId_interface_PixelChannelIdentifier_h
constexpr Packing(unsigned int row_w, unsigned int column_w, unsigned int flag_w, unsigned int adc_w)
static constexpr Packing packing()
static constexpr Packing thePacking
pixelchannelidentifierimpl::Packing Packing
col
Definition: cuy.py:1009
static int pixelToChannel(int row, int col)
static std::pair< int, int > channelToPixel(int ch)