File indexing completed on 2024-04-06 12:02:34
0001 #ifndef CondFormats_SiPixelObjects_SiPixelGainCalibration_h
0002 #define CondFormats_SiPixelObjects_SiPixelGainCalibration_h
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022 #include "CondFormats/Serialization/interface/Serializable.h"
0023
0024 #include <vector>
0025 #include <map>
0026 #include <iostream>
0027 #include <cstdint>
0028
0029 class SiPixelGainCalibration {
0030 public:
0031 struct DecodingStructure {
0032 unsigned int gain : 8;
0033 unsigned int ped : 8;
0034 };
0035
0036 struct DetRegistry {
0037 uint32_t detid;
0038 uint32_t ibegin;
0039 uint32_t iend;
0040 int ncols;
0041
0042 COND_SERIALIZABLE;
0043 };
0044
0045 class StrictWeakOrdering {
0046 public:
0047 bool operator()(const DetRegistry& p, const uint32_t& i) const { return p.detid < i; }
0048 };
0049
0050 typedef std::vector<char>::const_iterator ContainerIterator;
0051 typedef std::pair<ContainerIterator, ContainerIterator> Range;
0052 typedef std::vector<DetRegistry> Registry;
0053 typedef Registry::const_iterator RegistryIterator;
0054
0055
0056 SiPixelGainCalibration();
0057 SiPixelGainCalibration(float minPed, float maxPed, float minGain, float maxGain);
0058 ~SiPixelGainCalibration() {}
0059
0060 void initialize() {}
0061
0062 bool put(const uint32_t& detID, Range input, const int& nCols);
0063 const Range getRange(const uint32_t& detID) const;
0064 void getDetIds(std::vector<uint32_t>& DetIds_) const;
0065 const int getNCols(const uint32_t& detID) const;
0066 const std::pair<const Range, const int> getRangeAndNCols(const uint32_t& detID) const;
0067
0068 unsigned int getNumberOfRowsToAverageOver() const { return numberOfRowsToAverageOver_; }
0069 double getGainLow() const { return minGain_; }
0070 double getGainHigh() const { return maxGain_; }
0071 double getPedLow() const { return minPed_; }
0072 double getPedHigh() const { return maxPed_; }
0073
0074
0075 void setData(
0076 float ped, float gain, std::vector<char>& vped, bool thisPixelIsDead = false, bool thisPixelIsNoisy = false);
0077
0078 void setDeadPixel(std::vector<char>& vped) { setData(0, 0, vped, true, false); }
0079 void setNoisyPixel(std::vector<char>& vped) { setData(0, 0, vped, false, true); }
0080
0081 float getPed(const int& col, const int& row, const Range& range, const int& nCols, bool& isDead, bool& isNoisy) const;
0082 float getGain(const int& col, const int& row, const Range& range, const int& nCols, bool& isDead, bool& isNoisy) const;
0083
0084 private:
0085 float encodeGain(const float& gain);
0086 float encodePed(const float& ped);
0087 float decodeGain(unsigned int gain) const;
0088 float decodePed(unsigned int ped) const;
0089
0090 std::vector<char> v_pedestals;
0091 std::vector<DetRegistry> indexes;
0092 float minPed_, maxPed_, minGain_, maxGain_;
0093
0094
0095 unsigned int numberOfRowsToAverageOver_;
0096
0097 unsigned int nBinsToUseForEncoding_;
0098 unsigned int deadFlag_;
0099 unsigned int noisyFlag_;
0100
0101 COND_SERIALIZABLE;
0102 };
0103
0104 #endif