14 numberOfRowsToAverageOver_(1),
15 nBinsToUseForEncoding_(253),
19 throw cms::Exception(
"GainCalibration Payload configuration error")
20 <<
"[SiPixelGainCalibration::SiPixelGainCalibration] Dead flag was set to " <<
deadFlag_ 21 <<
", and it must be set less than or equal to 255";
34 throw cms::Exception(
"GainCalibration Payload configuration error")
35 <<
"[SiPixelGainCalibration::SiPixelGainCalibration] Dead flag was set to " <<
deadFlag_ 36 <<
", and it must be set less than or equal to 255";
42 Registry::iterator
p =
44 if (p !=
indexes.end() && p->detid == DetId)
47 size_t sd = input.second - input.first;
49 detregistry.
detid = DetId;
50 detregistry.
ncols = nCols;
63 if (p ==
indexes.end() || p->detid != DetId)
74 if (p ==
indexes.end() || p->detid != DetId)
81 const uint32_t&
DetId)
const {
84 if (p ==
indexes.end() || p->detid != DetId)
96 DetIds_.push_back(
p->detid);
101 float ped,
float gain, std::vector<char>& vped,
bool isDeadPixel,
bool isNoisyPixel) {
102 float theEncodedGain = 0;
103 float theEncodedPed = 0;
104 if (!isDeadPixel && !isNoisyPixel) {
109 unsigned int ped_ = (
static_cast<unsigned int>(theEncodedPed)) & 0xFF;
110 unsigned int gain_ = (
static_cast<unsigned int>(theEncodedGain)) & 0xFF;
120 unsigned int data = (ped_ << 8) | gain_;
121 vped.resize(vped.size() + 2);
123 ::memcpy((
void*)(&vped[vped.size() - 2]), (
void*)(&
data), 2);
127 const int&
col,
const int& row,
const Range&
range,
const int& nCols,
bool& isDead,
bool& isNoisy)
const {
128 int nRows = (range.second - range.first) / 2 / nCols;
129 const unsigned int ped = *(range.first + 1 + (col * nRows + row) * 2) & 0xFF;
130 if (col >= nCols || row >= nRows) {
132 <<
"[SiPixelGainCalibration::getPed] Pixel out of range: col " << col <<
" row " << row;
142 const int&
col,
const int& row,
const Range&
range,
const int& nCols,
bool& isDead,
bool& isNoisy)
const {
143 int nRows = (range.second - range.first) / 2 / nCols;
144 const unsigned int gain = *(range.first + (col * nRows + row) * 2) & 0xFF;
145 if (col >= nCols || row >= nRows) {
147 <<
"[SiPixelGainCalibration::getPed] Pixel out of range: col " << col <<
" row " << row;
157 if (gain < minGain_ || gain >
maxGain_) {
158 throw cms::Exception(
"InsertFailure") <<
"[SiPixelGainCalibration::encodeGain] Trying to encode gain (" << gain
159 <<
") out of range [" <<
minGain_ <<
"," << maxGain_ <<
"]\n";
168 if (ped < minPed_ || ped >
maxPed_) {
169 throw cms::Exception(
"InsertFailure") <<
"[SiPixelGainCalibration::encodePed] Trying to encode pedestal (" << ped
170 <<
") out of range [" <<
minPed_ <<
"," << maxPed_ <<
"]\n";
float decodeGain(unsigned int gain) const
std::vector< char > v_pedestals
unsigned int nBinsToUseForEncoding_
void getDetIds(std::vector< uint32_t > &DetIds_) const
std::vector< DetRegistry > indexes
const std::pair< const Range, const int > getRangeAndNCols(const uint32_t &detID) const
bool put(const uint32_t &detID, Range input, const int &nCols)
float getPed(const int &col, const int &row, const Range &range, const int &nCols, bool &isDead, bool &isNoisy) const
static std::string const input
unsigned int numberOfRowsToAverageOver_
float encodePed(const float &ped)
float getGain(const int &col, const int &row, const Range &range, const int &nCols, bool &isDead, bool &isNoisy) const
const Range getRange(const uint32_t &detID) const
Registry::const_iterator RegistryIterator
std::pair< ContainerIterator, ContainerIterator > Range
char data[epos_bytes_allocation]
const int getNCols(const uint32_t &detID) const
void setData(float ped, float gain, std::vector< char > &vped, bool thisPixelIsDead=false, bool thisPixelIsNoisy=false)
float encodeGain(const float &gain)
float decodePed(unsigned int ped) const