CMS 3D CMS Logo

SiPixelDbItem.cc
Go to the documentation of this file.
2 
3 #include <iostream>
4 #include <algorithm>
5 
6 
26 
27 
29 {
32  packedVal_ = oldValue | newNoise;
33 }
34 
36 {
39  packedVal_ = oldValue | newPedestal;
40 }
41 
43 {
44  // Convert gain into a shifted-integer
45  int mult_factor = 1 << packing_.gain_shift; // TO DO: check
46  unsigned short gInIntRep = int( g * mult_factor );
47 
48  PackedPixDbType newGain = (gInIntRep & packing_.gain_mask) << packing_.gain_shift;
50  packedVal_ = oldValue | newGain;
51 }
52 
54 {
57  packedVal_ = oldValue | newStatus;
58 }
59 
60 
61 
63 void SiPixelDbItem::set( short noise, short pedestal, float gain, char status)
64 {
65  // Convert gain into a shifted-integer
66  int mult_factor = 1 << packing_.gain_shift; // TO DO: check usage here
67  unsigned short gInIntRep = int( gain * mult_factor );
68 
69  packedVal_ =
70  (noise << packing_.noise_shift) |
71  (pedestal << packing_.pedestal_shift) |
72  (gInIntRep << packing_.gain_shift) |
73  (status << packing_.status_shift);
74 }
75 
76 
77 
78 
79 SiPixelDbItem::Packing::Packing(int noise_w, int pedestal_w,
80  int gain_w, int status_w)
81  : noise_width(noise_w), pedestal_width(pedestal_w), status_width(status_w)
82 {
83  // Constructor: pre-computes masks and shifts from field widths
84  // Order of fields (from right to left) is
85  // noise, pedestal, gain, status count.
86 
87  if ( noise_w+pedestal_w+gain_w+status_w != 32) {
88  std::cout << std::endl << "Error in SiPixelDbItem::Packing constructor:"
89  << "sum of field widths != 32" << std::endl;
90  // TO DO: throw an exception?
91  }
92 
93  // Fields are counted from right to left!
94 
95  noise_shift = 0;
96  pedestal_shift = noise_shift + noise_w;
97  gain_shift = pedestal_shift + pedestal_w;
98  status_shift = gain_shift + gain_w;
99 
100  // Ensure the complement of the correct
101  // number of bits:
102  PackedPixDbType zero32 = 0; // 32-bit wide
103 
104  noise_mask = ~(~zero32 << noise_w);
105  pedestal_mask = ~(~zero32 << pedestal_w);
106  gain_mask = ~(~zero32 << gain_w);
107  status_mask = ~(~zero32 << status_w);
108 }
109 
110 // Initialize the packing (order is: noise, pedestal, gain, status)
111 SiPixelDbItem::Packing SiPixelDbItem::packing_( 8, 8, 8, 8); // TO DO: TBD
112 
113 
static Packing packing_
Definition: SiPixelDbItem.h:68
short pedestal()
Definition: SiPixelDbItem.h:30
Pack the pixel information to use less memory.
Definition: SiPixelDbItem.h:50
The Signals That Services Can Subscribe To This is based on ActivityRegistry and is current per Services can connect to the signals distributed by the ActivityRegistry in order to monitor the activity of the application Each possible callback has some defined which we here list in angle e g
Definition: Activities.doc:4
void setStatus(char s)
uint32_t PackedPixDbType
Definition: SiPixelDbItem.h:24
PackedPixDbType pedestal_mask
Definition: SiPixelDbItem.h:63
PackedPixDbType status_mask
Definition: SiPixelDbItem.h:60
PackedPixDbType gain_mask
Definition: SiPixelDbItem.h:61
void set(short noise, short pedestal, float gain, char status)
A fast version which sets all in one go.
PackedPixDbType noise_mask
Definition: SiPixelDbItem.h:62
void setNoise(short n)
Packing(int noise_w, int pedestal_w, int gain_w, int status_w)
void setPedestal(short p)
PackedPixDbType packedVal_
Definition: SiPixelDbItem.h:46
void setGain(float g)