#include <CondFormats/SiPixelObjects/src/SiPixelGainCalibrationOffline.cc>
Classes | |
struct | DecodingStructure |
struct | DetRegistry |
class | StrictWeakOrdering |
Public Types | |
typedef std::vector< char > ::const_iterator | ContainerIterator |
typedef std::pair < ContainerIterator, ContainerIterator > | Range |
typedef std::vector< DetRegistry > | Registry |
typedef Registry::const_iterator | RegistryIterator |
Public Member Functions | |
void | getDetIds (std::vector< uint32_t > &DetIds_) const |
float | getGain (const int &col, const int &row, const Range &range, const int &nCols, bool &isDeadColumn, bool &isNoisyColumn) const |
double | getGainHigh () const |
double | getGainLow () const |
const int | getNCols (const uint32_t &detID) const |
unsigned int | getNumberOfRowsToAverageOver () const |
float | getPed (const int &col, const int &row, const Range &range, const int &nCols, bool &isDead, bool &isNoisy) const |
double | getPedHigh () const |
double | getPedLow () const |
const Range | getRange (const uint32_t &detID) const |
const std::pair< const Range, const int > | getRangeAndNCols (const uint32_t &detID) const |
bool | put (const uint32_t &detID, Range input, const int &nCols) |
void | setDataGain (float gain, const int &nRows, std::vector< char > &vped, bool thisColumnIsDead=false, bool thisColumnIsNoisy=false) |
void | setDataPedestal (float pedestal, std::vector< char > &vped, bool thisPixelIsDead=false, bool thisPixelIsNoisy=false) |
void | setDeadColumn (const int &nRows, std::vector< char > &vped) |
void | setDeadPixel (std::vector< char > &vped) |
void | setNoisyColumn (const int &nRows, std::vector< char > &vped) |
void | setNoisyPixel (std::vector< char > &vped) |
SiPixelGainCalibrationOffline (float minPed, float maxPed, float minGain, float maxGain) | |
SiPixelGainCalibrationOffline () | |
virtual | ~SiPixelGainCalibrationOffline () |
Private Member Functions | |
float | decodeGain (unsigned int gain) const |
float | decodePed (unsigned int ped) const |
float | encodeGain (const float &gain) |
float | encodePed (const float &ped) |
Private Attributes | |
unsigned int | deadFlag_ |
std::vector< DetRegistry > | indexes |
float | maxGain_ |
float | maxPed_ |
float | minGain_ |
float | minPed_ |
unsigned int | nBinsToUseForEncoding_ |
unsigned int | noisyFlag_ |
unsigned int | numberOfRowsToAverageOver_ |
std::vector< char > | v_pedestals |
Description: Gain calibration object for the Silicon Pixel detector. Stores pedestal at pixel granularity, gain at column granularity.
Implementation: <Notes on="" implementation>="">
Definition at line 27 of file SiPixelGainCalibrationOffline.h.
typedef std::vector<char>::const_iterator SiPixelGainCalibrationOffline::ContainerIterator |
Definition at line 47 of file SiPixelGainCalibrationOffline.h.
typedef std::pair<ContainerIterator, ContainerIterator> SiPixelGainCalibrationOffline::Range |
Definition at line 48 of file SiPixelGainCalibrationOffline.h.
typedef std::vector<DetRegistry> SiPixelGainCalibrationOffline::Registry |
Definition at line 49 of file SiPixelGainCalibrationOffline.h.
typedef Registry::const_iterator SiPixelGainCalibrationOffline::RegistryIterator |
Definition at line 50 of file SiPixelGainCalibrationOffline.h.
SiPixelGainCalibrationOffline::SiPixelGainCalibrationOffline | ( | ) |
Definition at line 9 of file SiPixelGainCalibrationOffline.cc.
References deadFlag_, Exception, and noisyFlag_.
: minPed_(0.), maxPed_(255.), minGain_(0.), maxGain_(255.), numberOfRowsToAverageOver_(80), nBinsToUseForEncoding_(253), deadFlag_(255), noisyFlag_(254) { if (deadFlag_ > 0xFF) throw cms::Exception("GainCalibration Payload configuration error") << "[SiPixelGainCalibrationOffline::SiPixelGainCalibrationOffline] Dead flag was set to " << deadFlag_ << ", and it must be set less than or equal to 255"; if (noisyFlag_ > 0xFF) throw cms::Exception("GainCalibration Payload configuration error") << "[SiPixelGainCalibrationOffline::SiPixelGainCalibrationOffline] Noisy flag was set to " << noisyFlag_ << ", and it must be set less than or equal to 255"; }
SiPixelGainCalibrationOffline::SiPixelGainCalibrationOffline | ( | float | minPed, |
float | maxPed, | ||
float | minGain, | ||
float | maxGain | ||
) |
Definition at line 27 of file SiPixelGainCalibrationOffline.cc.
References deadFlag_, Exception, and noisyFlag_.
: minPed_(minPed), maxPed_(maxPed), minGain_(minGain), maxGain_(maxGain), numberOfRowsToAverageOver_(80), nBinsToUseForEncoding_(253), deadFlag_(255), noisyFlag_(254) { if (deadFlag_ > 0xFF) throw cms::Exception("GainCalibration Payload configuration error") << "[SiPixelGainCalibrationOffline::SiPixelGainCalibrationOffline] Dead flag was set to " << deadFlag_ << ", and it must be set less than or equal to 255"; if (noisyFlag_ > 0xFF) throw cms::Exception("GainCalibration Payload configuration error") << "[SiPixelGainCalibrationOffline::SiPixelGainCalibrationOffline] Noisy flag was set to " << noisyFlag_ << ", and it must be set less than or equal to 255"; }
virtual SiPixelGainCalibrationOffline::~SiPixelGainCalibrationOffline | ( | ) | [inline, virtual] |
Definition at line 55 of file SiPixelGainCalibrationOffline.h.
{};
float SiPixelGainCalibrationOffline::decodeGain | ( | unsigned int | gain | ) | const [private] |
Definition at line 230 of file SiPixelGainCalibrationOffline.cc.
References maxGain_, minGain_, and nBinsToUseForEncoding_.
Referenced by getGain().
{ double precision = (maxGain_-minGain_)/static_cast<float>(nBinsToUseForEncoding_); float decodedGain = (float)(gain*precision + minGain_); return decodedGain; }
float SiPixelGainCalibrationOffline::decodePed | ( | unsigned int | ped | ) | const [private] |
Definition at line 222 of file SiPixelGainCalibrationOffline.cc.
References maxPed_, minPed_, and nBinsToUseForEncoding_.
Referenced by getPed().
{ double precision = (maxPed_-minPed_)/static_cast<float>(nBinsToUseForEncoding_); float decodedPed = (float)(ped*precision + minPed_); return decodedPed; }
float SiPixelGainCalibrationOffline::encodeGain | ( | const float & | gain | ) | [private] |
Definition at line 196 of file SiPixelGainCalibrationOffline.cc.
References Exception, maxGain_, minGain_, and nBinsToUseForEncoding_.
Referenced by setDataGain().
{ if(gain < minGain_ || gain > maxGain_ ) { throw cms::Exception("InsertFailure") << "[SiPixelGainCalibrationOffline::encodeGain] Trying to encode gain (" << gain << ") out of range [" << minGain_ << "," << maxGain_ << "]\n"; } else { double precision = (maxGain_-minGain_)/static_cast<float>(nBinsToUseForEncoding_); float encodedGain = (float)((gain-minGain_)/precision); return encodedGain; } }
float SiPixelGainCalibrationOffline::encodePed | ( | const float & | ped | ) | [private] |
Definition at line 209 of file SiPixelGainCalibrationOffline.cc.
References Exception, maxPed_, minPed_, and nBinsToUseForEncoding_.
Referenced by setDataPedestal().
{ if(ped < minPed_ || ped > maxPed_ ) { throw cms::Exception("InsertFailure") << "[SiPixelGainCalibrationOffline::encodePed] Trying to encode pedestal (" << ped << ") out of range [" << minPed_ << "," << maxPed_ << "]\n"; } else { double precision = (maxPed_-minPed_)/static_cast<float>(nBinsToUseForEncoding_); float encodedPed = (float)((ped-minPed_)/precision); return encodedPed; } }
void SiPixelGainCalibrationOffline::getDetIds | ( | std::vector< uint32_t > & | DetIds_ | ) | const |
Definition at line 93 of file SiPixelGainCalibrationOffline.cc.
References begin, end, indexes, and AlCaHLTBitMon_ParallelJobs::p.
{ // returns vector of DetIds in map SiPixelGainCalibrationOffline::RegistryIterator begin = indexes.begin(); SiPixelGainCalibrationOffline::RegistryIterator end = indexes.end(); for (SiPixelGainCalibrationOffline::RegistryIterator p=begin; p != end; ++p) { DetIds_.push_back(p->detid); } }
float SiPixelGainCalibrationOffline::getGain | ( | const int & | col, |
const int & | row, | ||
const Range & | range, | ||
const int & | nCols, | ||
bool & | isDeadColumn, | ||
bool & | isNoisyColumn | ||
) | const |
Definition at line 173 of file SiPixelGainCalibrationOffline.cc.
References SiPixelGainCalibrationOffline::DecodingStructure::datum, deadFlag_, decodeGain(), Exception, noisyFlag_, numberOfRowsToAverageOver_, and asciidump::s.
{ unsigned int lengthOfColumnData = (range.second-range.first)/nCols; //determine what row averaged range we are in (i.e. ROC 1 or ROC 2) unsigned int lengthOfAveragedDataInEachColumn = numberOfRowsToAverageOver_ + 1; unsigned int numberOfAveragedDataBlocksToSkip = row / numberOfRowsToAverageOver_; // gain average is stored in the last location of current row averaged column data block const DecodingStructure & s = (const DecodingStructure & ) *(range.first+(col)*(lengthOfColumnData) + ( (numberOfAveragedDataBlocksToSkip+1) * lengthOfAveragedDataInEachColumn) - 1); if ((s.datum & 0xFF) == deadFlag_) isDeadColumn = true; if ((s.datum & 0xFF) == noisyFlag_) isNoisyColumn = true; int maxRow = lengthOfColumnData - (lengthOfColumnData % numberOfRowsToAverageOver_) - 1; if (col >= nCols || row > maxRow){ throw cms::Exception("CorruptedData") << "[SiPixelGainCalibrationOffline::getPed] Pixel out of range: col " << col; } return decodeGain(s.datum & 0xFF); }
double SiPixelGainCalibrationOffline::getGainHigh | ( | ) | const [inline] |
Definition at line 69 of file SiPixelGainCalibrationOffline.h.
References maxGain_.
{ return maxGain_; }
double SiPixelGainCalibrationOffline::getGainLow | ( | ) | const [inline] |
Definition at line 68 of file SiPixelGainCalibrationOffline.h.
References minGain_.
{ return minGain_; }
const int SiPixelGainCalibrationOffline::getNCols | ( | const uint32_t & | detID | ) | const |
Definition at line 64 of file SiPixelGainCalibrationOffline.cc.
References indexes, and AlCaHLTBitMon_ParallelJobs::p.
{ // get number of columns of DetId RegistryIterator p = std::lower_bound(indexes.begin(),indexes.end(),DetId,SiPixelGainCalibrationOffline::StrictWeakOrdering()); if (p==indexes.end()|| p->detid!=DetId) return 0; else return p->ncols; }
unsigned int SiPixelGainCalibrationOffline::getNumberOfRowsToAverageOver | ( | ) | const [inline] |
Definition at line 67 of file SiPixelGainCalibrationOffline.h.
References numberOfRowsToAverageOver_.
{ return numberOfRowsToAverageOver_; }
float SiPixelGainCalibrationOffline::getPed | ( | const int & | col, |
const int & | row, | ||
const Range & | range, | ||
const int & | nCols, | ||
bool & | isDead, | ||
bool & | isNoisy | ||
) | const |
Definition at line 149 of file SiPixelGainCalibrationOffline.cc.
References SiPixelGainCalibrationOffline::DecodingStructure::datum, deadFlag_, decodePed(), Exception, noisyFlag_, numberOfRowsToAverageOver_, and asciidump::s.
{ unsigned int lengthOfColumnData = (range.second-range.first)/nCols; //determine what row averaged range we are in (i.e. ROC 1 or ROC 2) unsigned int lengthOfAveragedDataInEachColumn = numberOfRowsToAverageOver_ + 1; unsigned int numberOfAveragedDataBlocksToSkip = row / numberOfRowsToAverageOver_; unsigned int offSetInCorrectDataBlock = row % numberOfRowsToAverageOver_; const DecodingStructure & s = (const DecodingStructure & ) *(range.first + col*(lengthOfColumnData) + (numberOfAveragedDataBlocksToSkip * lengthOfAveragedDataInEachColumn) + offSetInCorrectDataBlock); int maxRow = lengthOfColumnData - (lengthOfColumnData % numberOfRowsToAverageOver_) - 1; if (col >= nCols || row > maxRow){ throw cms::Exception("CorruptedData") << "[SiPixelGainCalibrationOffline::getPed] Pixel out of range: col " << col << " row " << row; } if ((s.datum & 0xFF) == deadFlag_) isDead = true; if ((s.datum & 0xFF) == noisyFlag_) isNoisy = true; return decodePed(s.datum & 0xFF); }
double SiPixelGainCalibrationOffline::getPedHigh | ( | ) | const [inline] |
Definition at line 71 of file SiPixelGainCalibrationOffline.h.
References maxPed_.
{ return maxPed_; }
double SiPixelGainCalibrationOffline::getPedLow | ( | ) | const [inline] |
Definition at line 70 of file SiPixelGainCalibrationOffline.h.
References minPed_.
{ return minPed_; }
const SiPixelGainCalibrationOffline::Range SiPixelGainCalibrationOffline::getRange | ( | const uint32_t & | detID | ) | const |
Definition at line 73 of file SiPixelGainCalibrationOffline.cc.
References indexes, AlCaHLTBitMon_ParallelJobs::p, and v_pedestals.
{ // get SiPixelGainCalibrationOffline Range of DetId RegistryIterator p = std::lower_bound(indexes.begin(),indexes.end(),DetId,SiPixelGainCalibrationOffline::StrictWeakOrdering()); if (p==indexes.end()|| p->detid!=DetId) return SiPixelGainCalibrationOffline::Range(v_pedestals.end(),v_pedestals.end()); else return SiPixelGainCalibrationOffline::Range(v_pedestals.begin()+p->ibegin,v_pedestals.begin()+p->iend); }
const std::pair< const SiPixelGainCalibrationOffline::Range, const int > SiPixelGainCalibrationOffline::getRangeAndNCols | ( | const uint32_t & | detID | ) | const |
Definition at line 84 of file SiPixelGainCalibrationOffline.cc.
References indexes, AlCaHLTBitMon_ParallelJobs::p, and v_pedestals.
{ RegistryIterator p = std::lower_bound(indexes.begin(),indexes.end(),DetId,SiPixelGainCalibrationOffline::StrictWeakOrdering()); if (p==indexes.end()|| p->detid!=DetId) return std::make_pair(SiPixelGainCalibrationOffline::Range(v_pedestals.end(),v_pedestals.end()), 0); else return std::make_pair(SiPixelGainCalibrationOffline::Range(v_pedestals.begin()+p->ibegin,v_pedestals.begin()+p->iend), p->ncols); }
bool SiPixelGainCalibrationOffline::put | ( | const uint32_t & | detID, |
Range | input, | ||
const int & | nCols | ||
) |
Definition at line 45 of file SiPixelGainCalibrationOffline.cc.
References SiPixelGainCalibrationOffline::DetRegistry::detid, SiPixelGainCalibrationOffline::DetRegistry::ibegin, SiPixelGainCalibrationOffline::DetRegistry::iend, indexes, SiPixelGainCalibrationOffline::DetRegistry::ncols, AlCaHLTBitMon_ParallelJobs::p, and v_pedestals.
{ // put in SiPixelGainCalibrationOffline of DetId Registry::iterator p = std::lower_bound(indexes.begin(),indexes.end(),DetId,SiPixelGainCalibrationOffline::StrictWeakOrdering()); if (p!=indexes.end() && p->detid==DetId) return false; size_t sd= input.second-input.first; DetRegistry detregistry; detregistry.detid=DetId; detregistry.ncols=nCols; detregistry.ibegin=v_pedestals.size(); detregistry.iend=v_pedestals.size()+sd; indexes.insert(p,detregistry); v_pedestals.insert(v_pedestals.end(),input.first,input.second); return true; }
void SiPixelGainCalibrationOffline::setDataGain | ( | float | gain, |
const int & | nRows, | ||
std::vector< char > & | vped, | ||
bool | thisColumnIsDead = false , |
||
bool | thisColumnIsNoisy = false |
||
) |
Definition at line 102 of file SiPixelGainCalibrationOffline.cc.
References deadFlag_, encodeGain(), Exception, sistrip::extrainfo::gain_, noisyFlag_, and numberOfRowsToAverageOver_.
Referenced by setDeadColumn(), and setNoisyColumn().
{ float theEncodedGain=0; if(!thisColumnIsDead && !thisColumnIsNoisy) theEncodedGain = encodeGain(gain); unsigned int gain_ = (static_cast<unsigned int>(theEncodedGain)) & 0xFF; // if this whole column is dead, set a char based dead flag in the blob. if (thisColumnIsDead) gain_ = deadFlag_ & 0xFF; if (thisColumnIsNoisy) gain_ = noisyFlag_ & 0xFF; vped.resize(vped.size()+1); //check to make sure the column is being placed in the right place in the blob if (nRows != (int)numberOfRowsToAverageOver_) { throw cms::Exception("GainCalibration Payload configuration error") << "[SiPixelGainCalibrationOffline::setDataGain] You are setting a gain averaged over nRows = " << nRows << " where this payload is set ONLY to average over " << numberOfRowsToAverageOver_ << " nRows"; } if (vped.size() % (nRows + 1) != 0) { throw cms::Exception("FillError") << "[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"; } // insert in vector of char ::memcpy((void*)(&vped[vped.size()-1]),(void*)(&gain_),1); }
void SiPixelGainCalibrationOffline::setDataPedestal | ( | float | pedestal, |
std::vector< char > & | vped, | ||
bool | thisPixelIsDead = false , |
||
bool | thisPixelIsNoisy = false |
||
) |
Definition at line 133 of file SiPixelGainCalibrationOffline.cc.
References deadFlag_, encodePed(), and noisyFlag_.
Referenced by setDeadPixel(), and setNoisyPixel().
{ float theEncodedPedestal = encodePed(pedestal); unsigned int ped_ = (static_cast<unsigned int>(theEncodedPedestal)) & 0xFF; if (thisPixelIsDead) ped_ = deadFlag_ & 0xFF; if (thisPixelIsNoisy) ped_ = noisyFlag_ & 0xFF; vped.resize(vped.size()+1); // insert in vector of char ::memcpy((void*)(&vped[vped.size()-1]),(void*)(&ped_),1); }
void SiPixelGainCalibrationOffline::setDeadColumn | ( | const int & | nRows, |
std::vector< char > & | vped | ||
) | [inline] |
Definition at line 75 of file SiPixelGainCalibrationOffline.h.
References setDataGain().
{ setDataGain(0 /*dummy value, not used*/, nRows, vped, true ); }
void SiPixelGainCalibrationOffline::setDeadPixel | ( | std::vector< char > & | vped | ) | [inline] |
Definition at line 74 of file SiPixelGainCalibrationOffline.h.
References setDataPedestal().
{ setDataPedestal(0 /*dummy value, not used*/, vped, true ); }
void SiPixelGainCalibrationOffline::setNoisyColumn | ( | const int & | nRows, |
std::vector< char > & | vped | ||
) | [inline] |
Definition at line 79 of file SiPixelGainCalibrationOffline.h.
References setDataGain().
{ setDataGain(0 /*dummy value, not used*/, nRows, vped, false, true ); }
void SiPixelGainCalibrationOffline::setNoisyPixel | ( | std::vector< char > & | vped | ) | [inline] |
Definition at line 78 of file SiPixelGainCalibrationOffline.h.
References setDataPedestal().
{ setDataPedestal(0 /*dummy value, not used*/, vped, false, true ); }
unsigned int SiPixelGainCalibrationOffline::deadFlag_ [private] |
Definition at line 99 of file SiPixelGainCalibrationOffline.h.
Referenced by getGain(), getPed(), setDataGain(), setDataPedestal(), and SiPixelGainCalibrationOffline().
std::vector<DetRegistry> SiPixelGainCalibrationOffline::indexes [private] |
Definition at line 94 of file SiPixelGainCalibrationOffline.h.
Referenced by getDetIds(), getNCols(), getRange(), getRangeAndNCols(), and put().
float SiPixelGainCalibrationOffline::maxGain_ [private] |
Definition at line 95 of file SiPixelGainCalibrationOffline.h.
Referenced by decodeGain(), encodeGain(), and getGainHigh().
float SiPixelGainCalibrationOffline::maxPed_ [private] |
Definition at line 95 of file SiPixelGainCalibrationOffline.h.
Referenced by decodePed(), encodePed(), and getPedHigh().
float SiPixelGainCalibrationOffline::minGain_ [private] |
Definition at line 95 of file SiPixelGainCalibrationOffline.h.
Referenced by decodeGain(), encodeGain(), and getGainLow().
float SiPixelGainCalibrationOffline::minPed_ [private] |
Definition at line 95 of file SiPixelGainCalibrationOffline.h.
Referenced by decodePed(), encodePed(), and getPedLow().
unsigned int SiPixelGainCalibrationOffline::nBinsToUseForEncoding_ [private] |
Definition at line 98 of file SiPixelGainCalibrationOffline.h.
Referenced by decodeGain(), decodePed(), encodeGain(), and encodePed().
unsigned int SiPixelGainCalibrationOffline::noisyFlag_ [private] |
Definition at line 100 of file SiPixelGainCalibrationOffline.h.
Referenced by getGain(), getPed(), setDataGain(), setDataPedestal(), and SiPixelGainCalibrationOffline().
unsigned int SiPixelGainCalibrationOffline::numberOfRowsToAverageOver_ [private] |
Definition at line 97 of file SiPixelGainCalibrationOffline.h.
Referenced by getGain(), getNumberOfRowsToAverageOver(), getPed(), and setDataGain().
std::vector<char> SiPixelGainCalibrationOffline::v_pedestals [private] |
Definition at line 93 of file SiPixelGainCalibrationOffline.h.
Referenced by getRange(), getRangeAndNCols(), and put().