00001 #ifndef CondFormats_SiPixelObjects_SiPixelGainCalibrationOffline_h
00002 #define CondFormats_SiPixelObjects_SiPixelGainCalibrationOffline_h
00003
00004
00005
00006
00007
00015
00016
00017
00018
00019
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
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
00064 void setDataGain ( float gain, const int& nRows, std::vector<char>& vped , bool thisColumnIsDead = false);
00065 void setDataPedestal ( float pedestal, std::vector<char>& vped , bool thisPixelIsDead = false);
00066
00067 unsigned int getNumberOfRowsToAverageOver() const { return numberOfRowsToAverageOver_; }
00068
00069
00070 void setDeadPixel(std::vector<char>& vped) { setDataPedestal(0 , vped, true ); }
00071 void setDeadColumn(const int& nRows, std::vector<char>& vped) { setDataGain(0 , nRows, vped, true ); }
00072
00073
00074 float getPed (const int& col, const int& row, const Range& range, const int& nCols, bool& isDead) const;
00075 float getGain (const int& col, const int& row, const Range& range, const int& nCols, bool& isDeadColumn) const;
00076
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;
00086 std::vector<DetRegistry> indexes;
00087 float minPed_, maxPed_, minGain_, maxGain_;
00088
00089 unsigned int numberOfRowsToAverageOver_;
00090 unsigned int nBinsToUseForEncoding_;
00091 unsigned int deadFlag_;
00092
00093 };
00094
00095 #endif