14 numberOfRowsToAverageOver_(80),
15 nBinsToUseForEncoding_(253),
20 throw cms::Exception(
"GainCalibration Payload configuration error")
21 <<
"[SiPixelGainCalibrationOffline::SiPixelGainCalibrationOffline] Dead flag was set to " <<
deadFlag_ <<
", 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_ <<
", and it must be set less than or equal to 255";
32 numberOfRowsToAverageOver_(80),
33 nBinsToUseForEncoding_(253),
38 throw cms::Exception(
"GainCalibration Payload configuration error")
39 <<
"[SiPixelGainCalibrationOffline::SiPixelGainCalibrationOffline] Dead flag was set to " <<
deadFlag_ <<
", and it must be set less than or equal to 255";
41 throw cms::Exception(
"GainCalibration Payload configuration error")
42 <<
"[SiPixelGainCalibrationOffline::SiPixelGainCalibrationOffline] Noisy flag was set to " <<
noisyFlag_ <<
", and it must be set less than or equal to 255";
49 if (p!=
indexes.end() && p->detid==DetId)
52 size_t sd= input.second-input.first;
54 detregistry.
detid=DetId;
55 detregistry.
ncols=nCols;
67 if (p==
indexes.end()|| p->detid!=DetId)
77 if (p==
indexes.end()|| p->detid!=DetId)
83 const std::pair<const SiPixelGainCalibrationOffline::Range, const int>
86 if (p==
indexes.end()|| p->detid!=DetId)
98 DetIds_.push_back(
p->detid);
104 float theEncodedGain=0;
105 if(!thisColumnIsDead && !thisColumnIsNoisy)
108 unsigned int gain_ = (
static_cast<unsigned int>(theEncodedGain)) & 0xFF;
111 if (thisColumnIsDead)
113 if (thisColumnIsNoisy)
116 vped.resize(vped.size()+1);
120 throw cms::Exception(
"GainCalibration Payload configuration error")
121 <<
"[SiPixelGainCalibrationOffline::setDataGain] You are setting a gain averaged over nRows = " << nRows <<
" where this payload is set ONLY to average over " <<
numberOfRowsToAverageOver_ <<
" nRows";
124 if (vped.size() % (nRows + 1) != 0)
127 <<
"[SiPixelGainCalibrationOffline::setDataGain] Column gain average (OR SETTING AN ENTIRE COLUMN DEAD/NOISY) must be filled after the pedestal for each row has been added. An additional source of this error would be setting a pixel dead/noisy AND setting its pedestal";
130 ::memcpy((
void*)(&vped[vped.size()-1]),(
void*)(&
gain_),1);
135 float theEncodedPedestal =
encodePed(pedestal);
137 unsigned int ped_ = (
static_cast<unsigned int>(theEncodedPedestal)) & 0xFF;
141 if (thisPixelIsNoisy)
144 vped.resize(vped.size()+1);
146 ::memcpy((
void*)(&vped[vped.size()-1]),(
void*)(&ped_),1);
151 unsigned int lengthOfColumnData = (range.second-range.first)/nCols;
157 const DecodingStructure &
s = (
const DecodingStructure & ) *(range.first + col*(lengthOfColumnData) + (numberOfAveragedDataBlocksToSkip * lengthOfAveragedDataInEachColumn) + offSetInCorrectDataBlock);
160 if (col >= nCols || row > maxRow){
162 <<
"[SiPixelGainCalibrationOffline::getPed] Pixel out of range: col " << col <<
" row " << row;
175 unsigned int lengthOfColumnData = (range.second-range.first)/nCols;
181 const DecodingStructure &
s = (
const DecodingStructure & ) *(range.first+(col)*(lengthOfColumnData) + ( (numberOfAveragedDataBlocksToSkip+1) * lengthOfAveragedDataInEachColumn) - 1);
186 isNoisyColumn =
true;
189 if (col >= nCols || row > maxRow){
191 <<
"[SiPixelGainCalibrationOffline::getPed] Pixel out of range: col " <<
col;
198 if(gain < minGain_ || gain >
maxGain_ ) {
200 <<
"[SiPixelGainCalibrationOffline::encodeGain] Trying to encode gain (" << gain <<
") out of range [" <<
minGain_ <<
"," << maxGain_ <<
"]\n";
203 float encodedGain = (float)((gain-
minGain_)/precision);
211 if(ped < minPed_ || ped >
maxPed_ ) {
213 <<
"[SiPixelGainCalibrationOffline::encodePed] Trying to encode pedestal (" << ped <<
") out of range [" <<
minPed_ <<
"," << maxPed_ <<
"]\n";
216 float encodedPed = (float)((ped-
minPed_)/precision);
225 float decodedPed = (float)(ped*precision +
minPed_);
233 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)
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
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