Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 12:51:31

0001 #ifndef CondFormats_SiPixelObjects_SiPixelDbItem_h
0002 #define CondFormats_SiPixelObjects_SiPixelDbItem_h
0003 
0004 //----------------------------------------------------------------------------
0005 //! \class SiPixelPedestals
0006 //! \brief Event Setup object which holds DB information for all pixels.
0007 //!
0008 //! \description Event Setup object which holds DB information for all pixels.
0009 //! DB info for a single pixel is held in SiPixelDbItem, which contains
0010 //! pedestal, noise, gain and status bits packed into an 32-bit wide unsigned
0011 //! int.  The bit allocation is the following:
0012 //! bits [31:24] - status   (0 if good, bits TBD set if not good)
0013 //! bits [23:16] - gain     (upper 4 bits integer part, 4 bits fractional part)
0014 //! bits  [15:8] - pedestal (upper 6 bits integer part, 2 bits fractional part)
0015 //! bits   [7:0] - noise    (upper 6 bits integer part, 2 bits fractional part)
0016 //-----------------------------------------------------------------------------
0017 
0018 #include "CondFormats/Serialization/interface/Serializable.h"
0019 #include <cstdint>
0020 
0021 class SiPixelDbItem {
0022   typedef uint32_t PackedPixDbType;
0023 
0024 public:
0025   SiPixelDbItem() : packedVal_(0) { set(2, 0, 1.0, 0); }  // TO DO: is noise==2 in shifted rep or not???
0026   ~SiPixelDbItem() {}
0027   inline short noise() { return (packedVal_ >> packing_.noise_shift) & packing_.noise_mask; }
0028   inline short pedestal() { return (packedVal_ >> packing_.pedestal_shift) & packing_.pedestal_mask; }
0029   inline float gain() { return (packedVal_ >> packing_.gain_shift) & packing_.gain_mask; }
0030   inline char status() { return (packedVal_ >> packing_.status_shift) & packing_.status_mask; }
0031   inline PackedPixDbType packedValue() { return packedVal_; }
0032 
0033   inline void setPackedVal(PackedPixDbType p) { packedVal_ = p; }
0034 
0035   // The following setters are not inline since they are more complicated:
0036   void setNoise(short n);
0037   void setPedestal(short p);
0038   void setGain(float g);
0039   void setStatus(char s);
0040   void set(short noise, short pedestal, float gain, char status);
0041 
0042 private:
0043   PackedPixDbType packedVal_;
0044 
0045   //! Pack the pixel information to use less memory
0046 
0047   class Packing {
0048   public:
0049     //--- Constructor: pre-computes masks and shifts from field widths
0050     Packing(int noise_w, int pedestal_w, int gain_w, int status_w);
0051 
0052     //--- Public data:
0053     int status_shift;
0054     int gain_shift;
0055     int noise_shift;
0056     int pedestal_shift;
0057     PackedPixDbType status_mask;
0058     PackedPixDbType gain_mask;
0059     PackedPixDbType noise_mask;
0060     PackedPixDbType pedestal_mask;
0061     int noise_width;
0062     int pedestal_width;
0063     int status_width;
0064   };
0065   static Packing packing_;
0066 
0067   COND_SERIALIZABLE;
0068 };
0069 
0070 #endif