CMS 3D CMS Logo

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