File indexing completed on 2024-04-06 12:02:34
0001 #ifndef CondFormats_SiPixelObjects_SiPixelGainCalibrationOffline_h
0002 #define CondFormats_SiPixelObjects_SiPixelGainCalibrationOffline_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 SiPixelGainCalibrationOffline {
0030 public:
0031 struct DecodingStructure {
0032 unsigned int datum : 8;
0033 };
0034
0035 struct DetRegistry {
0036 uint32_t detid;
0037 uint32_t ibegin;
0038 uint32_t iend;
0039 int ncols;
0040
0041 COND_SERIALIZABLE;
0042 };
0043
0044 class StrictWeakOrdering {
0045 public:
0046 bool operator()(const DetRegistry& p, const uint32_t& i) const { return p.detid < i; }
0047 };
0048
0049 typedef std::vector<char>::const_iterator ContainerIterator;
0050 typedef std::pair<ContainerIterator, ContainerIterator> Range;
0051 typedef std::vector<DetRegistry> Registry;
0052 typedef Registry::const_iterator RegistryIterator;
0053
0054
0055 SiPixelGainCalibrationOffline();
0056 SiPixelGainCalibrationOffline(float minPed, float maxPed, float minGain, float maxGain);
0057 ~SiPixelGainCalibrationOffline() {}
0058
0059 void initialize() {}
0060
0061 bool put(const uint32_t& detID, Range input, const int& nCols);
0062 const Range getRange(const uint32_t& detID) const;
0063 void getDetIds(std::vector<uint32_t>& DetIds_) const;
0064 const int getNCols(const uint32_t& detID) const;
0065 const std::pair<const Range, const int> getRangeAndNCols(const uint32_t& detID) const;
0066
0067
0068 void setDataGain(float gain,
0069 const int& nRows,
0070 std::vector<char>& vped,
0071 bool thisColumnIsDead = false,
0072 bool thisColumnIsNoisy = false);
0073 void setDataPedestal(float pedestal,
0074 std::vector<char>& vped,
0075 bool thisPixelIsDead = false,
0076 bool thisPixelIsNoisy = false);
0077
0078 unsigned int getNumberOfRowsToAverageOver() const { return numberOfRowsToAverageOver_; }
0079 double getGainLow() const { return minGain_; }
0080 double getGainHigh() const { return maxGain_; }
0081 double getPedLow() const { return minPed_; }
0082 double getPedHigh() const { return maxPed_; }
0083
0084
0085 void setDeadPixel(std::vector<char>& vped) { setDataPedestal(0 , vped, true); }
0086 void setDeadColumn(const int& nRows, std::vector<char>& vped) {
0087 setDataGain(0 , nRows, vped, true);
0088 }
0089
0090
0091 void setNoisyPixel(std::vector<char>& vped) { setDataPedestal(0 , vped, false, true); }
0092 void setNoisyColumn(const int& nRows, std::vector<char>& vped) {
0093 setDataGain(0 , nRows, vped, false, true);
0094 }
0095
0096
0097 float getPed(const int& col, const int& row, const Range& range, const int& nCols, bool& isDead, bool& isNoisy) const;
0098 float getGain(const int& col,
0099 const int& row,
0100 const Range& range,
0101 const int& nCols,
0102 bool& isDeadColumn,
0103 bool& isNoisyColumn) const;
0104
0105 private:
0106 float encodeGain(const float& gain);
0107 float encodePed(const float& ped);
0108 float decodeGain(unsigned int gain) const;
0109 float decodePed(unsigned int ped) const;
0110
0111 std::vector<char> v_pedestals;
0112 std::vector<DetRegistry> indexes;
0113 float minPed_, maxPed_, minGain_, maxGain_;
0114
0115
0116 unsigned int numberOfRowsToAverageOver_;
0117
0118 unsigned int nBinsToUseForEncoding_;
0119 unsigned int deadFlag_;
0120 unsigned int noisyFlag_;
0121
0122 COND_SERIALIZABLE;
0123 };
0124
0125 #endif