14 numberOfRowsToAverageOver_(80),
15 nBinsToUseForEncoding_(253),
19 throw cms::Exception(
"GainCalibration Payload configuration error")
20 <<
"[SiPixelGainCalibrationOffline::SiPixelGainCalibrationOffline] Dead flag was set to " <<
deadFlag_
21 <<
", and it must be set less than or equal to 255";
23 throw cms::Exception(
"GainCalibration Payload configuration error")
24 <<
"[SiPixelGainCalibrationOffline::SiPixelGainCalibrationOffline] Noisy flag was set to " <<
noisyFlag_
25 <<
", and it must be set less than or equal to 255";
33 numberOfRowsToAverageOver_(80),
34 nBinsToUseForEncoding_(253),
38 throw cms::Exception(
"GainCalibration Payload configuration error")
39 <<
"[SiPixelGainCalibrationOffline::SiPixelGainCalibrationOffline] Dead flag was set to " <<
deadFlag_
40 <<
", and it must be set less than or equal to 255";
42 throw cms::Exception(
"GainCalibration Payload configuration error")
43 <<
"[SiPixelGainCalibrationOffline::SiPixelGainCalibrationOffline] Noisy flag was set to " <<
noisyFlag_
44 <<
", and it must be set less than or equal to 255";
50 Registry::iterator
p =
52 if (p !=
indexes.end() && p->detid == DetId)
55 size_t sd = input.second - input.first;
57 detregistry.
detid = DetId;
58 detregistry.
ncols = nCols;
71 if (p ==
indexes.end() || p->detid != DetId)
82 if (p ==
indexes.end() || p->detid != DetId)
89 const uint32_t&
DetId)
const {
92 if (p ==
indexes.end() || p->detid != DetId)
95 return std::make_pair(
104 DetIds_.push_back(
p->detid);
109 float gain,
const int& nRows, std::vector<char>& vped,
bool thisColumnIsDead,
bool thisColumnIsNoisy) {
110 float theEncodedGain = 0;
111 if (!thisColumnIsDead && !thisColumnIsNoisy)
114 unsigned int gain_ = (
static_cast<unsigned int>(theEncodedGain)) & 0xFF;
117 if (thisColumnIsDead)
119 if (thisColumnIsNoisy)
122 vped.resize(vped.size() + 1);
125 throw cms::Exception(
"GainCalibration Payload configuration error")
126 <<
"[SiPixelGainCalibrationOffline::setDataGain] You are setting a gain averaged over nRows = " << nRows
130 if (vped.size() % (nRows + 1) != 0) {
132 <<
"[SiPixelGainCalibrationOffline::setDataGain] Column gain average (OR SETTING AN ENTIRE COLUMN DEAD/NOISY) "
133 "must be filled after the pedestal for each row has been added. An additional source of this error would be "
134 "setting a pixel dead/noisy AND setting its pedestal";
137 ::memcpy((
void*)(&vped[vped.size() - 1]), (
void*)(&
gain_), 1);
141 std::vector<char>& vped,
142 bool thisPixelIsDead,
143 bool thisPixelIsNoisy) {
144 float theEncodedPedestal =
encodePed(pedestal);
146 unsigned int ped_ = (
static_cast<unsigned int>(theEncodedPedestal)) & 0xFF;
150 if (thisPixelIsNoisy)
153 vped.resize(vped.size() + 1);
155 ::memcpy((
void*)(&vped[vped.size() - 1]), (
void*)(&ped_), 1);
159 const int&
col,
const int& row,
const Range&
range,
const int& nCols,
bool& isDead,
bool& isNoisy)
const {
160 unsigned int lengthOfColumnData = (range.second - range.first) / nCols;
166 const unsigned int datum =
167 *(range.first + col * lengthOfColumnData + numberOfAveragedDataBlocksToSkip * lengthOfAveragedDataInEachColumn +
168 offSetInCorrectDataBlock) &
172 if (col >= nCols || row > maxRow) {
174 <<
"[SiPixelGainCalibrationOffline::getPed] Pixel out of range: col " << col <<
" row " << row;
190 bool& isNoisyColumn)
const {
191 unsigned int lengthOfColumnData = (range.second - range.first) / nCols;
197 const unsigned int datum = *(range.first + col * lengthOfColumnData +
198 ((numberOfAveragedDataBlocksToSkip + 1) * lengthOfAveragedDataInEachColumn) - 1) &
204 isNoisyColumn =
true;
207 if (col >= nCols || row > maxRow) {
209 <<
"[SiPixelGainCalibrationOffline::getPed] Pixel out of range: col " << col <<
" row " << row;
216 if (gain < minGain_ || gain >
maxGain_) {
217 throw cms::Exception(
"InsertFailure") <<
"[SiPixelGainCalibrationOffline::encodeGain] Trying to encode gain ("
218 << gain <<
") out of range [" <<
minGain_ <<
"," << maxGain_ <<
"]\n";
221 float encodedGain = (float)((gain -
minGain_) / precision);
227 if (ped < minPed_ || ped >
maxPed_) {
228 throw cms::Exception(
"InsertFailure") <<
"[SiPixelGainCalibrationOffline::encodePed] Trying to encode pedestal ("
229 << ped <<
") out of range [" <<
minPed_ <<
"," << maxPed_ <<
"]\n";
232 float encodedPed = (float)((ped -
minPed_) / precision);
239 float decodedPed = (float)(ped * precision +
minPed_);
245 float decodedGain = (float)(gain * precision +
minGain_);
float getGain(const int &col, const int &row, const Range &range, const int &nCols, bool &isDeadColumn, bool &isNoisyColumn) const
std::vector< char > v_pedestals
void setDataPedestal(float pedestal, std::vector< char > &vped, bool thisPixelIsDead=false, bool thisPixelIsNoisy=false)
unsigned int numberOfRowsToAverageOver_
float getPed(const int &col, const int &row, const Range &range, const int &nCols, bool &isDead, bool &isNoisy) const
std::pair< ContainerIterator, ContainerIterator > Range
const int getNCols(const uint32_t &detID) const
void setDataGain(float gain, const int &nRows, std::vector< char > &vped, bool thisColumnIsDead=false, bool thisColumnIsNoisy=false)
static std::string const input
const uint16_t range(const Frame &aFrame)
SiPixelGainCalibrationOffline()
float encodeGain(const float &gain)
float encodePed(const float &ped)
const Range getRange(const uint32_t &detID) const
float decodeGain(unsigned int gain) const
const std::pair< const Range, const int > getRangeAndNCols(const uint32_t &detID) const
std::vector< DetRegistry > indexes
__host__ __device__ constexpr RandomIt lower_bound(RandomIt first, RandomIt last, const T &value, Compare comp={})
void getDetIds(std::vector< uint32_t > &DetIds_) const
bool put(const uint32_t &detID, Range input, const int &nCols)
unsigned int nBinsToUseForEncoding_
float decodePed(unsigned int ped) const
Registry::const_iterator RegistryIterator