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 =
58 detregistry.
ncols = nCols;
89 const uint32_t&
DetId)
const {
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) {
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 ("
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";