CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_2_9/src/CondFormats/SiPixelObjects/interface/SiPixelGainCalibrationOffline.h

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