00001 #ifndef DATAFORMATS_PIXELCHANMNELIDENTIFIER_H 00002 #define DATAFORMATS_PIXELCHANMNELIDENTIFIER_H 00003 00004 #include <utility> 00005 00006 class PixelChannelIdentifier{ 00007 public: 00008 00009 typedef unsigned int PackedDigiType; 00010 typedef unsigned int ChannelType; 00011 00012 static std::pair<int,int> channelToPixel( int ch) { 00013 int row = ( ch >> thePacking.column_width) & thePacking.row_mask; 00014 int col = ch & thePacking.column_mask; 00015 return std::pair<int,int>(row,col); 00016 } 00017 00018 static int pixelToChannel( int row, int col) { 00019 return (row << thePacking.column_width) | col; 00020 } 00021 00022 private: 00027 class Packing { 00028 public: 00029 00030 // Constructor: pre-computes masks and shifts from field widths 00031 Packing(const int row_w, const int column_w, 00032 const int time_w, const int adc_w); 00033 00034 // public data: 00035 int adc_shift; 00036 int time_shift; 00037 int row_shift; 00038 int column_shift; 00039 00040 PackedDigiType adc_mask; 00041 PackedDigiType time_mask; 00042 PackedDigiType row_mask; 00043 PackedDigiType column_mask; 00044 00045 int row_width; 00046 int column_width; 00047 int adc_width; 00048 00049 int max_row; 00050 int max_column; 00051 int max_adc; 00052 }; 00053 00054 public: 00055 static Packing thePacking; 00056 }; 00057 00058 00059 #endif