Skip to content

Commit

Permalink
Reserve one bit for flagging individual pixels
Browse files Browse the repository at this point in the history
  • Loading branch information
tsusa committed Jul 15, 2021
1 parent 9082188 commit 62ee660
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 10 deletions.
14 changes: 7 additions & 7 deletions DataFormats/SiPixelDetId/interface/PixelChannelIdentifier.h
Expand Up @@ -13,17 +13,17 @@ namespace pixelchanelidentifierimpl {
using PackedDigiType = unsigned int;

// Constructor: pre-computes masks and shifts from field widths
constexpr Packing(unsigned int row_w, unsigned int column_w, unsigned int time_w, unsigned int adc_w)
constexpr Packing(unsigned int row_w, unsigned int column_w, unsigned int flag_w, unsigned int adc_w)
: row_width(row_w),
column_width(column_w),
adc_width(adc_w),
row_shift(0),
column_shift(row_shift + row_w),
time_shift(column_shift + column_w),
adc_shift(time_shift + time_w),
flag_shift(column_shift + column_w),
adc_shift(flag_shift + flag_w),
row_mask(~(~0U << row_w)),
column_mask(~(~0U << column_w)),
time_mask(~(~0U << time_w)),
flag_mask(~(~0U << flag_w)),
adc_mask(~(~0U << adc_w)),
rowcol_mask(~(~0U << (column_w + row_w))),
max_row(row_mask),
Expand All @@ -36,12 +36,12 @@ namespace pixelchanelidentifierimpl {

const int row_shift;
const int column_shift;
const int time_shift;
const int flag_shift;
const int adc_shift;

const PackedDigiType row_mask;
const PackedDigiType column_mask;
const PackedDigiType time_mask;
const PackedDigiType flag_mask;
const PackedDigiType adc_mask;
const PackedDigiType rowcol_mask;

Expand Down Expand Up @@ -69,7 +69,7 @@ class PixelChannelIdentifier {
public:
constexpr static Packing packing() { return Packing(8, 9, 4, 11); }

constexpr static Packing thePacking = {11, 11, 0, 10};
constexpr static Packing thePacking = {11, 10, 0, 10};
};

#endif
10 changes: 7 additions & 3 deletions DataFormats/SiPixelDigi/interface/PixelDigi.h
Expand Up @@ -19,6 +19,7 @@ class PixelDigi {
explicit PixelDigi(PackedDigiType packed_value) : theData(packed_value) {}

PixelDigi(int row, int col, int adc) { init(row, col, adc); }
PixelDigi(int row, int col, int adc, int flag) { init(row, col, adc, flag); }

PixelDigi(int chan, int adc) {
std::pair<int, int> rc = channelToPixel(chan);
Expand All @@ -27,7 +28,7 @@ class PixelDigi {

PixelDigi() : theData(0) {}

void init(int row, int col, int adc) {
void init(int row, int col, int adc, int flag = 0) {
#ifdef FIXME_DEBUG
// This check is for the maximal row or col number that can be packed
// in a PixelDigi. The actual number of rows or columns in a detector
Expand All @@ -45,7 +46,8 @@ class PixelDigi {

theData = (row << PixelChannelIdentifier::thePacking.row_shift) |
(col << PixelChannelIdentifier::thePacking.column_shift) |
(adc << PixelChannelIdentifier::thePacking.adc_shift);
(adc << PixelChannelIdentifier::thePacking.adc_shift) |
(flag << PixelChannelIdentifier::thePacking.flag_shift);
}

// Access to digi information
Expand All @@ -56,7 +58,9 @@ class PixelDigi {
return (theData >> PixelChannelIdentifier::thePacking.column_shift) &
PixelChannelIdentifier::thePacking.column_mask;
}
//int time() const {return (theData >> PixelChannelIdentifier::thePacking.time_shift) & PixelChannelIdentifier::thePacking.time_mask;}
int flag() const {
return (theData >> PixelChannelIdentifier::thePacking.flag_shift) & PixelChannelIdentifier::thePacking.flag_mask;
}
unsigned short adc() const {
return (theData >> PixelChannelIdentifier::thePacking.adc_shift) & PixelChannelIdentifier::thePacking.adc_mask;
}
Expand Down

0 comments on commit 62ee660

Please sign in to comment.