00001 #ifndef CondFormats_SiPixelObjects_SiPixelGainCalibration_h
00002 #define CondFormats_SiPixelObjects_SiPixelGainCalibration_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 SiPixelGainCalibration {
00028
00029 public:
00030
00031 struct DecodingStructure{
00032 unsigned int gain :8;
00033 unsigned int ped :8;
00034
00035 };
00036
00037 struct DetRegistry{
00038 uint32_t detid;
00039 uint32_t ibegin;
00040 uint32_t iend;
00041 int ncols;
00042 };
00043
00044 class StrictWeakOrdering{
00045 public:
00046 bool operator() (const DetRegistry& p,const uint32_t& i) const {return p.detid < i;}
00047 };
00048
00049 typedef std::vector<char>::const_iterator ContainerIterator;
00050 typedef std::pair<ContainerIterator, ContainerIterator> Range;
00051 typedef std::vector<DetRegistry> Registry;
00052 typedef Registry::const_iterator RegistryIterator;
00053
00054
00055 SiPixelGainCalibration();
00056 SiPixelGainCalibration(float minPed, float maxPed, float minGain, float maxGain);
00057 virtual ~SiPixelGainCalibration(){};
00058
00059 bool put(const uint32_t& detID,Range input, const int& nCols);
00060 const Range getRange(const uint32_t& detID) const;
00061 void getDetIds(std::vector<uint32_t>& DetIds_) const;
00062 const int getNCols(const uint32_t& detID) const;
00063 const std::pair<const Range, const int> getRangeAndNCols(const uint32_t& detID) const;
00064
00065 unsigned int getNumberOfRowsToAverageOver() const { return numberOfRowsToAverageOver_; }
00066
00067
00068 void setData(float ped, float gain, std::vector<char>& vped, bool thisPixelIsDead = false);
00069
00070 void setDeadPixel(std::vector<char>& vped) { setData(0, 0, vped, true ); }
00071
00072 float getPed (const int& col, const int& row, const Range& range, const int& nCols, bool& isDead) const;
00073 float getGain (const int& col, const int& row, const Range& range, const int& nCols, bool& isDead) const;
00074
00075 private:
00076
00077 float encodeGain(const float& gain);
00078 float encodePed (const float& ped);
00079 float decodeGain(unsigned int gain) const;
00080 float decodePed (unsigned int ped) const;
00081
00082 std::vector<char> v_pedestals;
00083 std::vector<DetRegistry> indexes;
00084 float minPed_, maxPed_, minGain_, maxGain_;
00085
00086 unsigned int numberOfRowsToAverageOver_;
00087 unsigned int nBinsToUseForEncoding_;
00088 unsigned int deadFlag_;
00089
00090 };
00091
00092 #endif