CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_6_1_2_SLHC4_patch1/src/CondFormats/SiPixelObjects/interface/SiPixelDbItem.h

Go to the documentation of this file.
00001 #ifndef CondFormats_SiPixelObjects_SiPixelDbItem_h
00002 #define CondFormats_SiPixelObjects_SiPixelDbItem_h
00003 
00004 //----------------------------------------------------------------------------
00016 //-----------------------------------------------------------------------------
00017 
00018 #include <boost/cstdint.hpp>
00019 
00020 class SiPixelDbItem 
00021 {
00022   typedef uint32_t PackedPixDbType;
00023 
00024  public:
00025   SiPixelDbItem() : packedVal_(0) { set(2, 0, 1.0, 0); }  // TO DO: is noise==2 in shifted rep or not???
00026   ~SiPixelDbItem() {}
00027   inline short  noise()     { return (packedVal_ >> packing_.noise_shift    ) & packing_.noise_mask   ; }
00028   inline short  pedestal()  { return (packedVal_ >> packing_.pedestal_shift ) & packing_.pedestal_mask; }
00029   inline float  gain()      { return (packedVal_ >> packing_.gain_shift     ) & packing_.gain_mask    ; }
00030   inline char   status()    { return (packedVal_ >> packing_.status_shift   ) & packing_.status_mask  ; }
00031   inline PackedPixDbType packedValue() { return packedVal_; }
00032 
00033   inline void   setPackedVal( PackedPixDbType p ) { packedVal_ = p; }
00034 
00035   // The following setters are not inline since they are more complicated:
00036   void   setNoise   (short n);
00037   void   setPedestal(short p);
00038   void   setGain    (float g);
00039   void   setStatus  (char  s);
00040   void   set( short noise, short pedestal, float gain, char status);
00041 
00042 
00043  private:
00044   PackedPixDbType packedVal_;
00045 
00047 
00048   class Packing {
00049   public:
00050     //--- Constructor: pre-computes masks and shifts from field widths
00051     Packing(int noise_w, int pedestal_w, int gain_w, int status_w);
00052 
00053     //--- Public data:
00054     int status_shift;
00055     int gain_shift;
00056     int noise_shift;
00057     int pedestal_shift;
00058     PackedPixDbType status_mask;
00059     PackedPixDbType gain_mask;
00060     PackedPixDbType noise_mask;
00061     PackedPixDbType pedestal_mask;
00062     int noise_width;
00063     int pedestal_width;
00064     int status_width;
00065   };
00066   static Packing packing_;
00067 
00068 };
00069 
00070 #endif