File indexing completed on 2024-04-06 12:02:34
0001 #ifndef CondFormats_SiPixelObjects_SiPixelGainCalibrationForHLT_h
0002 #define CondFormats_SiPixelObjects_SiPixelGainCalibrationForHLT_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 SiPixelGainCalibrationForHLT {
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 SiPixelGainCalibrationForHLT();
0057 SiPixelGainCalibrationForHLT(float minPed, float maxPed, float minGain, float maxGain);
0058 ~SiPixelGainCalibrationForHLT() {}
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 float getGainLow() const { return minGain_; }
0070 float getGainHigh() const { return maxGain_; }
0071 float getPedLow() const { return minPed_; }
0072 float getPedHigh() const { return maxPed_; }
0073
0074 std::vector<char> const& data() const { return v_pedestals; }
0075 std::vector<DetRegistry> const& getIndexes() const { return indexes; }
0076
0077
0078 void setData(
0079 float ped, float gain, std::vector<char>& vped, bool thisColumnIsDead = false, bool thisColumnIsNoisy = false);
0080 void setDeadColumn(const int& nRows, std::vector<char>& vped) {
0081 setData(0, 0 , vped, true, false);
0082 }
0083 void setNoisyColumn(const int& nRows, std::vector<char>& vped) {
0084 setData(0, 0 , vped, false, true);
0085 }
0086
0087 std::pair<float, float> getPedAndGain(const int& col,
0088 const int& row,
0089 const Range& range,
0090 const int& nCols,
0091 bool& isDeadColumn,
0092 bool& isNoisyColumn) const;
0093
0094 float getPed(const int& col,
0095 const int& row,
0096 const Range& range,
0097 const int& nCols,
0098 bool& isDeadColumn,
0099 bool& isNoisyColumn) const;
0100 float getGain(const int& col,
0101 const int& row,
0102 const Range& range,
0103 const int& nCols,
0104 bool& isDeadColumn,
0105 bool& isNoisyColumn) const;
0106
0107 private:
0108 float encodeGain(const float& gain);
0109 float encodePed(const float& ped);
0110 float decodeGain(unsigned int gain) const { return float(gain) * gainPrecision + minGain_; }
0111 float decodePed(unsigned int ped) const { return float(ped) * pedPrecision + minPed_; }
0112
0113 std::vector<char> v_pedestals;
0114 std::vector<DetRegistry> indexes;
0115 float minPed_, maxPed_, minGain_, maxGain_;
0116
0117 float pedPrecision, gainPrecision;
0118
0119
0120 unsigned int numberOfRowsToAverageOver_;
0121
0122 unsigned int nBinsToUseForEncoding_;
0123 unsigned int deadFlag_;
0124 unsigned int noisyFlag_;
0125
0126 COND_SERIALIZABLE;
0127 };
0128
0129 #endif