#include <CondFormats/SiPixelObjects/interface/SiPixelDbItem.h>
Public Member Functions | |
float | gain () |
short | noise () |
PackedPixDbType | packedValue () |
short | pedestal () |
void | set (short noise, short pedestal, float gain, char status) |
A fast version which sets all in one go. | |
void | setGain (float g) |
void | setNoise (short n) |
The logic of individual setters: First, we put the new value into newXXX, which is a 32-bit word which has the new value at the bits where it should go, and 0's everywhere else. | |
void | setPackedVal (PackedPixDbType p) |
void | setPedestal (short p) |
void | setStatus (char s) |
SiPixelDbItem () | |
char | status () |
~SiPixelDbItem () | |
Private Types | |
typedef uint32_t | PackedPixDbType |
Private Attributes | |
PackedPixDbType | packedVal_ |
Static Private Attributes | |
static Packing | packing_ |
Classes | |
class | Packing |
Pack the pixel information to use less memory. More... |
Definition at line 20 of file SiPixelDbItem.h.
typedef uint32_t SiPixelDbItem::PackedPixDbType [private] |
Definition at line 22 of file SiPixelDbItem.h.
SiPixelDbItem::SiPixelDbItem | ( | ) | [inline] |
Definition at line 25 of file SiPixelDbItem.h.
00025 : packedVal_(0) { set(2, 0, 1.0, 0); } // TO DO: is noise==2 in shifted rep or not???
SiPixelDbItem::~SiPixelDbItem | ( | ) | [inline] |
float SiPixelDbItem::gain | ( | ) | [inline] |
Definition at line 29 of file SiPixelDbItem.h.
References SiPixelDbItem::Packing::gain_mask, SiPixelDbItem::Packing::gain_shift, packedVal_, and packing_.
00029 { return (packedVal_ >> packing_.gain_shift ) & packing_.gain_mask ; }
short SiPixelDbItem::noise | ( | ) | [inline] |
Definition at line 27 of file SiPixelDbItem.h.
References SiPixelDbItem::Packing::noise_mask, SiPixelDbItem::Packing::noise_shift, packedVal_, and packing_.
00027 { return (packedVal_ >> packing_.noise_shift ) & packing_.noise_mask ; }
PackedPixDbType SiPixelDbItem::packedValue | ( | ) | [inline] |
short SiPixelDbItem::pedestal | ( | ) | [inline] |
Definition at line 28 of file SiPixelDbItem.h.
References packedVal_, packing_, SiPixelDbItem::Packing::pedestal_mask, and SiPixelDbItem::Packing::pedestal_shift.
00028 { return (packedVal_ >> packing_.pedestal_shift ) & packing_.pedestal_mask; }
void SiPixelDbItem::set | ( | short | noise, | |
short | pedestal, | |||
float | gain, | |||
char | status | |||
) |
A fast version which sets all in one go.
Definition at line 63 of file SiPixelDbItem.cc.
References SiPixelDbItem::Packing::gain_shift, int, SiPixelDbItem::Packing::noise_shift, packedVal_, packing_, SiPixelDbItem::Packing::pedestal_shift, and SiPixelDbItem::Packing::status_shift.
00064 { 00065 // Convert gain into a shifted-integer 00066 int mult_factor = 1 << packing_.gain_shift; // TO DO: check usage here 00067 unsigned short gInIntRep = int( gain * mult_factor ); 00068 00069 packedVal_ = 00070 (noise << packing_.noise_shift) | 00071 (pedestal << packing_.pedestal_shift) | 00072 (gInIntRep << packing_.gain_shift) | 00073 (status << packing_.status_shift); 00074 }
void SiPixelDbItem::setGain | ( | float | g | ) |
Definition at line 42 of file SiPixelDbItem.cc.
References SiPixelDbItem::Packing::gain_mask, SiPixelDbItem::Packing::gain_shift, int, packedVal_, and packing_.
00043 { 00044 // Convert gain into a shifted-integer 00045 int mult_factor = 1 << packing_.gain_shift; // TO DO: check 00046 unsigned short gInIntRep = int( g * mult_factor ); 00047 00048 PackedPixDbType newGain = (gInIntRep & packing_.gain_mask) << packing_.gain_shift; 00049 PackedPixDbType oldValue = packedVal_ & ( ~(packing_.gain_mask << packing_.gain_shift) ); 00050 packedVal_ = oldValue | newGain; 00051 }
void SiPixelDbItem::setNoise | ( | short | n | ) |
The logic of individual setters: First, we put the new value into newXXX, which is a 32-bit word which has the new value at the bits where it should go, and 0's everywhere else.
To make it, we:
Next, we prepare the oldValue with a whole where newXXX needs to go. ~(mask << shift) has 1's everywhere except where the new value will go, so AND-ing packedVal_ with it creates a `whole' for the new value.
Finally, the new value is an OR of the two (since the wholes have 0's)
Example: 00 03 c3 02 -- old, new one must blow c3 away, so we AND with ff ff 00 ff, and get 00 03 00 02. The new number is now positioned to be ff ff a2 ff, and then we AND these two and get 00 03 a2 02. We have replaced c3 with a2.
Definition at line 28 of file SiPixelDbItem.cc.
References SiPixelDbItem::Packing::noise_mask, SiPixelDbItem::Packing::noise_shift, packedVal_, and packing_.
00029 { 00030 PackedPixDbType newNoise = (n & packing_.noise_mask) << packing_.noise_shift; 00031 PackedPixDbType oldValue = packedVal_ & ( ~(packing_.noise_mask << packing_.noise_shift) ); 00032 packedVal_ = oldValue | newNoise; 00033 }
void SiPixelDbItem::setPackedVal | ( | PackedPixDbType | p | ) | [inline] |
void SiPixelDbItem::setPedestal | ( | short | p | ) |
Definition at line 35 of file SiPixelDbItem.cc.
References packedVal_, packing_, SiPixelDbItem::Packing::pedestal_mask, and SiPixelDbItem::Packing::pedestal_shift.
00036 { 00037 PackedPixDbType newPedestal = (p & packing_.pedestal_mask) << packing_.pedestal_shift; 00038 PackedPixDbType oldValue = packedVal_ & ( ~(packing_.pedestal_mask << packing_.pedestal_shift) ); 00039 packedVal_ = oldValue | newPedestal; 00040 }
void SiPixelDbItem::setStatus | ( | char | s | ) |
Definition at line 53 of file SiPixelDbItem.cc.
References packedVal_, packing_, SiPixelDbItem::Packing::status_mask, and SiPixelDbItem::Packing::status_shift.
00054 { 00055 PackedPixDbType newStatus = (s & packing_.status_mask) << packing_.status_shift; 00056 PackedPixDbType oldValue = packedVal_ & ( ~(packing_.status_mask << packing_.status_shift) ); 00057 packedVal_ = oldValue | newStatus; 00058 }
char SiPixelDbItem::status | ( | ) | [inline] |
Definition at line 30 of file SiPixelDbItem.h.
References packedVal_, packing_, SiPixelDbItem::Packing::status_mask, and SiPixelDbItem::Packing::status_shift.
00030 { return (packedVal_ >> packing_.status_shift ) & packing_.status_mask ; }
PackedPixDbType SiPixelDbItem::packedVal_ [private] |
Definition at line 44 of file SiPixelDbItem.h.
Referenced by gain(), noise(), packedValue(), pedestal(), set(), setGain(), setNoise(), setPackedVal(), setPedestal(), setStatus(), and status().
SiPixelDbItem::Packing SiPixelDbItem::packing_ [static, private] |
Definition at line 66 of file SiPixelDbItem.h.
Referenced by gain(), noise(), pedestal(), set(), setGain(), setNoise(), setPedestal(), setStatus(), and status().