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>
6 
8 public:
9  typedef unsigned int PackedDigiType;
10  typedef unsigned int ChannelType;
11 
12  static std::pair<int, int> channelToPixel(int ch) {
13  int row = (ch >> thePacking.column_width) & thePacking.row_mask;
14  int col = ch & thePacking.column_mask;
15  return std::pair<int, int>(row, col);
16  }
17 
18  static int pixelToChannel(int row, int col) { return (row << thePacking.column_width) | col; }
19 
24  class Packing {
25  public:
26  // Constructor: pre-computes masks and shifts from field widths
27  // gcc4.8: sorry, unimplemented: use of the value of the object being constructed in a constant expression
28  // no constexpr yet....
29  Packing(unsigned int row_w, unsigned int column_w, unsigned int time_w, unsigned int adc_w)
30  : row_width(row_w),
31  column_width(column_w),
32  adc_width(adc_w),
33  row_shift(0),
34  column_shift(row_shift + row_w),
35  time_shift(column_shift + column_w),
36  adc_shift(time_shift + time_w),
37  row_mask(~(~0U << row_w)),
38  column_mask(~(~0U << column_w)),
39  time_mask(~(~0U << time_w)),
40  adc_mask(~(~0U << adc_w)),
41  rowcol_mask(~(~0U << (column_w + row_w))),
44  max_adc(adc_mask) {}
45 
46  int row_width;
48  int adc_width;
49 
50  int row_shift;
53  int adc_shift;
54 
55  PackedDigiType row_mask;
56  PackedDigiType column_mask;
57  PackedDigiType time_mask;
58  PackedDigiType adc_mask;
59  PackedDigiType rowcol_mask;
60 
61  int max_row;
63  int max_adc;
64  };
65 
66 public:
67  //#ifndef CMS_NOCXX11
68  static Packing packing() { return Packing(8, 9, 4, 11); }
69 
70  static const Packing thePacking;
71 
72  //#else
73  //static constexpr Packing packing() { return Packing(8, 9, 4, 11);}
74 
75  //static constexpr Packing thePacking = packing();
76  //#endif
77 };
78 
79 #endif
static const Packing thePacking
Packing(unsigned int row_w, unsigned int column_w, unsigned int time_w, unsigned int adc_w)
col
Definition: cuy.py:1010
static int pixelToChannel(int row, int col)
static std::pair< int, int > channelToPixel(int ch)