CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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(int row_w, int column_w,
34  int time_w, 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(~(~0 << row_w))
41  ,column_mask( ~(~0 << column_w))
42  ,time_mask(~(~0 << time_w))
43  ,adc_mask(~(~0 << adc_w))
44  ,rowcol_mask(~(~0 << (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 
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
static int pixelToChannel(int row, int col)
Packing(int row_w, int column_w, int time_w, int adc_w)
int col
Definition: cuy.py:1008