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