CMS 3D CMS Logo

/afs/cern.ch/work/a/aaltunda/public/www/CMSSW_6_2_5/src/CondFormats/SiPixelObjects/interface/SiPixelGainCalibrationForHLT.h

Go to the documentation of this file.
00001 #ifndef CondFormats_SiPixelObjects_SiPixelGainCalibrationForHLT_h
00002 #define CondFormats_SiPixelObjects_SiPixelGainCalibrationForHLT_h
00003 // -*- C++ -*-
00004 //
00005 // Package:    SiPixelObjects
00006 // Class:      SiPixelGainCalibrationForHLT
00007 // 
00015 //
00016 // Original Author:  Vincenzo Chiochia
00017 //         Created:  Tue 8 12:31:25 CEST 2007
00018 //         Modified: Evan Friis
00019 // $Id: SiPixelGainCalibrationForHLT.h,v 1.6 2009/02/17 19:04:02 rougny Exp $
00020 //
00021 //
00022 #include<vector>
00023 #include<map>
00024 #include<iostream>
00025 #include<boost/cstdint.hpp>
00026 
00027 class SiPixelGainCalibrationForHLT {
00028 
00029  public:
00030 
00031   struct DecodingStructure{  
00032     unsigned int gain :8;
00033     unsigned int ped  :8;
00034   };
00035   
00036   struct DetRegistry{
00037     uint32_t detid;
00038     uint32_t ibegin;
00039     uint32_t iend;
00040     int      ncols;
00041   };
00042   
00043   class StrictWeakOrdering{
00044   public:
00045     bool operator() (const DetRegistry& p,const uint32_t& i) const {return p.detid < i;}
00046   };
00047   
00048   typedef std::vector<char>::const_iterator                ContainerIterator;  
00049   typedef std::pair<ContainerIterator, ContainerIterator>  Range;      
00050   typedef std::vector<DetRegistry>                         Registry;
00051   typedef Registry::const_iterator                         RegistryIterator;
00052   
00053   // Constructors
00054   SiPixelGainCalibrationForHLT();
00055   SiPixelGainCalibrationForHLT(float minPed, float maxPed, float minGain, float maxGain);
00056   virtual ~SiPixelGainCalibrationForHLT(){};
00057 
00058   bool  put(const uint32_t& detID,Range input, const int& nCols);
00059   const Range getRange(const uint32_t& detID) const;
00060   void  getDetIds(std::vector<uint32_t>& DetIds_) const;
00061   const int getNCols(const uint32_t& detID) const;
00062   const std::pair<const Range, const int> getRangeAndNCols(const uint32_t& detID) const;
00063 
00064   unsigned int getNumberOfRowsToAverageOver() const { return numberOfRowsToAverageOver_; }
00065   double getGainLow() const { return minGain_; }
00066   double getGainHigh() const { return maxGain_; }
00067   double getPedLow() const { return minPed_; }
00068   double getPedHigh() const { return maxPed_; }
00069 
00070   // Set and get public methods
00071   void  setData(float ped, float gain, std::vector<char>& vped, bool thisColumnIsDead = false, bool thisColumnIsNoisy = false);
00072   void  setDeadColumn(const int& nRows, std::vector<char>& vped)  { setData(0, 0 /*dummy values, not used*/, vped, true, false); }
00073   void  setNoisyColumn(const int& nRows, std::vector<char>& vped) { setData(0, 0 /*dummy values, not used*/, vped, false, true); }
00074 
00075   float getPed   (const int& col, const int& row, const Range& range, const int& nCols, bool& isDeadColumn, bool& isNoisyColumn ) const;
00076   float getGain  (const int& col, const int& row, const Range& range, const int& nCols, bool& isDeadColumn, bool& isNoisyColumn ) const;
00077 
00078   private:
00079 
00080   float   encodeGain(const float& gain);
00081   float   encodePed (const float& ped);
00082   float   decodeGain(unsigned int gain) const;
00083   float   decodePed (unsigned int ped) const;
00084 
00085   std::vector<char> v_pedestals; //@@@ blob streaming doesn't work with uint16_t and with classes
00086   std::vector<DetRegistry> indexes;
00087   float  minPed_, maxPed_, minGain_, maxGain_;
00088 
00089   unsigned int numberOfRowsToAverageOver_;   //THIS WILL BE HARDCODED TO 80 (all rows in a ROC) DON'T CHANGE UNLESS YOU KNOW WHAT YOU ARE DOING! 
00090   unsigned int nBinsToUseForEncoding_;
00091   unsigned int deadFlag_;
00092   unsigned int noisyFlag_;
00093 };
00094     
00095 #endif