14 numberOfRowsToAverageOver_(80),
15 nBinsToUseForEncoding_(253),
20 throw cms::Exception(
"GainCalibration Payload configuration error")
21 <<
"[SiPixelGainCalibrationHLT::SiPixelGainCalibrationHLT] Dead flag was set to " <<
deadFlag_
22 <<
", and it must be set less than or equal to 255";
30 numberOfRowsToAverageOver_(80),
31 nBinsToUseForEncoding_(253),
36 throw cms::Exception(
"GainCalibration Payload configuration error")
37 <<
"[SiPixelGainCalibrationHLT::SiPixelGainCalibrationHLT] Dead flag was set to " <<
deadFlag_
38 <<
", and it must be set less than or equal to 255";
49 Registry::iterator
p =
51 if (p !=
indexes.end() && p->detid == DetId)
54 size_t sd = input.second - input.first;
56 detregistry.
detid = DetId;
59 detregistry.
ncols = nCols;
70 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 ped,
float gain, std::vector<char>& vped,
bool thisColumnIsDead,
bool thisColumnIsNoisy) {
110 float theEncodedGain = 0;
111 float theEncodedPed = 0;
112 if (!thisColumnIsDead && !thisColumnIsNoisy) {
117 unsigned int ped_ = (
static_cast<unsigned int>(theEncodedPed)) & 0xFF;
118 unsigned int gain_ = (
static_cast<unsigned int>(theEncodedGain)) & 0xFF;
120 if (thisColumnIsDead) {
123 }
else if (thisColumnIsNoisy) {
128 unsigned int data = (ped_ << 8) | gain_;
129 vped.resize(vped.size() + 2);
131 ::memcpy((
void*)(&vped[vped.size() - 2]), (
void*)(&
data), 2);
139 bool& isNoisyColumn)
const {
141 unsigned int lengthOfColumnData = (range.second - range.first) / nCols;
142 unsigned int lengthOfAveragedDataInEachColumn = 2;
144 const unsigned int pos = col * lengthOfColumnData + lengthOfAveragedDataInEachColumn * numberOfDataBlocksToSkip;
145 const unsigned int gain = *(range.first + pos) & 0xFF;
146 const unsigned int ped = *(range.first + pos + 1) & 0xFF;
167 bool& isNoisyColumn)
const {
171 unsigned int lengthOfColumnData = (range.second - range.first) / nCols;
172 unsigned int lengthOfAveragedDataInEachColumn = 2;
174 const unsigned int ped =
175 *(range.first + 1 + col * lengthOfColumnData + lengthOfAveragedDataInEachColumn * numberOfDataBlocksToSkip) &
181 isNoisyColumn =
true;
184 if (col >= nCols || row > maxRow) {
186 <<
"[SiPixelGainCalibrationForHLT::getPed] Pixel out of range: col " << col <<
" row: " << row;
196 bool& isNoisyColumn)
const {
198 unsigned int lengthOfColumnData = (range.second - range.first) / nCols;
199 unsigned int lengthOfAveragedDataInEachColumn = 2;
201 const unsigned int gain =
202 *(range.first + col * lengthOfColumnData + lengthOfAveragedDataInEachColumn * numberOfDataBlocksToSkip) & 0xFF;
207 isNoisyColumn =
true;
210 if (col >= nCols || row > maxRow) {
212 <<
"[SiPixelGainCalibrationForHLT::getGain] Pixel out of range: col " << col <<
" row: " << row;
218 if (gain < minGain_ || gain >
maxGain_) {
219 throw cms::Exception(
"InsertFailure") <<
"[SiPixelGainCalibrationForHLT::encodeGain] Trying to encode gain ("
220 << gain <<
") out of range [" <<
minGain_ <<
"," << maxGain_ <<
"]\n";
223 float encodedGain = (float)((gain -
minGain_) / precision);
229 if (ped < minPed_ || ped >
maxPed_) {
230 throw cms::Exception(
"InsertFailure") <<
"[SiPixelGainCalibrationForHLT::encodePed] Trying to encode pedestal ("
231 << ped <<
") out of range [" <<
minPed_ <<
"," << maxPed_ <<
"]\n";
234 float encodedPed = (float)((ped -
minPed_) / precision);
std::pair< float, float > getPedAndGain(const int &col, const int &row, const Range &range, const int &nCols, bool &isDeadColumn, bool &isNoisyColumn) const
SiPixelGainCalibrationForHLT()
void setData(float ped, float gain, std::vector< char > &vped, bool thisColumnIsDead=false, bool thisColumnIsNoisy=false)
float encodePed(const float &ped)
void getDetIds(std::vector< uint32_t > &DetIds_) const
const std::pair< const Range, const int > getRangeAndNCols(const uint32_t &detID) const
std::vector< char > const & data() const
std::vector< DetRegistry > indexes
std::pair< ContainerIterator, ContainerIterator > Range
static std::string const input
const uint16_t range(const Frame &aFrame)
float getGain(const int &col, const int &row, const Range &range, const int &nCols, bool &isDeadColumn, bool &isNoisyColumn) const
unsigned int numberOfRowsToAverageOver_
float decodePed(unsigned int ped) const
float getPed(const int &col, const int &row, const Range &range, const int &nCols, bool &isDeadColumn, bool &isNoisyColumn) const
float decodeGain(unsigned int gain) const
float encodeGain(const float &gain)
bool put(const uint32_t &detID, Range input, const int &nCols)
Registry::const_iterator RegistryIterator
unsigned int nBinsToUseForEncoding_
const Range getRange(const uint32_t &detID) const
__host__ __device__ constexpr RandomIt lower_bound(RandomIt first, RandomIt last, const T &value, Compare comp={})
const int getNCols(const uint32_t &detID) const
std::vector< char > v_pedestals