CMS 3D CMS Logo

SiPixelDbItem.cc
Go to the documentation of this file.
2 
3 #include <iostream>
4 #include <algorithm>
5 
25 
29  packedVal_ = oldValue | newNoise;
30 }
31 
35  packedVal_ = oldValue | newPedestal;
36 }
37 
39  // Convert gain into a shifted-integer
40  int mult_factor = 1 << packing_.gain_shift; // TO DO: check
41  unsigned short gInIntRep = int(g * mult_factor);
42 
43  PackedPixDbType newGain = (gInIntRep & packing_.gain_mask) << packing_.gain_shift;
45  packedVal_ = oldValue | newGain;
46 }
47 
51  packedVal_ = oldValue | newStatus;
52 }
53 
55 void SiPixelDbItem::set(short noise, short pedestal, float gain, char status) {
56  // Convert gain into a shifted-integer
57  int mult_factor = 1 << packing_.gain_shift; // TO DO: check usage here
58  unsigned short gInIntRep = int(gain * mult_factor);
59 
61  (gInIntRep << packing_.gain_shift) | (status << packing_.status_shift);
62 }
63 
64 SiPixelDbItem::Packing::Packing(int noise_w, int pedestal_w, int gain_w, int status_w)
65  : noise_width(noise_w), pedestal_width(pedestal_w), status_width(status_w) {
66  // Constructor: pre-computes masks and shifts from field widths
67  // Order of fields (from right to left) is
68  // noise, pedestal, gain, status count.
69 
70  if (noise_w + pedestal_w + gain_w + status_w != 32) {
71  std::cout << std::endl
72  << "Error in SiPixelDbItem::Packing constructor:"
73  << "sum of field widths != 32" << std::endl;
74  // TO DO: throw an exception?
75  }
76 
77  // Fields are counted from right to left!
78 
79  noise_shift = 0;
80  pedestal_shift = noise_shift + noise_w;
81  gain_shift = pedestal_shift + pedestal_w;
82  status_shift = gain_shift + gain_w;
83 
84  // Ensure the complement of the correct
85  // number of bits:
86  PackedPixDbType zero32 = 0; // 32-bit wide
87 
88  noise_mask = ~(~zero32 << noise_w);
89  pedestal_mask = ~(~zero32 << pedestal_w);
90  gain_mask = ~(~zero32 << gain_w);
91  status_mask = ~(~zero32 << status_w);
92 }
93 
94 // Initialize the packing (order is: noise, pedestal, gain, status)
95 SiPixelDbItem::Packing SiPixelDbItem::packing_(8, 8, 8, 8); // TO DO: TBD
static Packing packing_
Definition: SiPixelDbItem.h:65
short pedestal()
Definition: SiPixelDbItem.h:28
Pack the pixel information to use less memory.
Definition: SiPixelDbItem.h:47
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:22
PackedPixDbType pedestal_mask
Definition: SiPixelDbItem.h:60
PackedPixDbType status_mask
Definition: SiPixelDbItem.h:57
PackedPixDbType gain_mask
Definition: SiPixelDbItem.h:58
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:59
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:43
void setGain(float g)