#include <CondFormats/SiPixelObjects/src/SiPixelGainCalibration.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 &isDead, bool &isNoisy) 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 | setData (float ped, float gain, std::vector< char > &vped, bool thisPixelIsDead=false, bool thisPixelIsNoisy=false) |
void | setDeadPixel (std::vector< char > &vped) |
void | setNoisyPixel (std::vector< char > &vped) |
SiPixelGainCalibration (float minPed, float maxPed, float minGain, float maxGain) | |
SiPixelGainCalibration () | |
virtual | ~SiPixelGainCalibration () |
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. Store gain/pedestal information at pixel granularity
Implementation: <Notes on="" implementation>="">
Definition at line 27 of file SiPixelGainCalibration.h.
typedef std::vector<char>::const_iterator SiPixelGainCalibration::ContainerIterator |
Definition at line 49 of file SiPixelGainCalibration.h.
typedef std::pair<ContainerIterator, ContainerIterator> SiPixelGainCalibration::Range |
Definition at line 50 of file SiPixelGainCalibration.h.
typedef std::vector<DetRegistry> SiPixelGainCalibration::Registry |
Definition at line 51 of file SiPixelGainCalibration.h.
typedef Registry::const_iterator SiPixelGainCalibration::RegistryIterator |
Definition at line 52 of file SiPixelGainCalibration.h.
SiPixelGainCalibration::SiPixelGainCalibration | ( | ) |
Definition at line 9 of file SiPixelGainCalibration.cc.
References deadFlag_, and Exception.
: minPed_(0.), maxPed_(255.), minGain_(0.), maxGain_(255.), numberOfRowsToAverageOver_(1), nBinsToUseForEncoding_(253), deadFlag_(255), noisyFlag_(254) { if (deadFlag_ > 0xFF) throw cms::Exception("GainCalibration Payload configuration error") << "[SiPixelGainCalibration::SiPixelGainCalibration] Dead flag was set to " << deadFlag_ << ", and it must be set less than or equal to 255"; }
SiPixelGainCalibration::SiPixelGainCalibration | ( | float | minPed, |
float | maxPed, | ||
float | minGain, | ||
float | maxGain | ||
) |
Definition at line 24 of file SiPixelGainCalibration.cc.
References deadFlag_, and Exception.
: minPed_(minPed), maxPed_(maxPed), minGain_(minGain), maxGain_(maxGain), numberOfRowsToAverageOver_(1), nBinsToUseForEncoding_(253), deadFlag_(255), noisyFlag_(254) { if (deadFlag_ > 0xFF) throw cms::Exception("GainCalibration Payload configuration error") << "[SiPixelGainCalibration::SiPixelGainCalibration] Dead flag was set to " << deadFlag_ << ", and it must be set less than or equal to 255"; }
virtual SiPixelGainCalibration::~SiPixelGainCalibration | ( | ) | [inline, virtual] |
Definition at line 57 of file SiPixelGainCalibration.h.
{};
float SiPixelGainCalibration::decodeGain | ( | unsigned int | gain | ) | const [private] |
Definition at line 188 of file SiPixelGainCalibration.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 SiPixelGainCalibration::decodePed | ( | unsigned int | ped | ) | const [private] |
Definition at line 180 of file SiPixelGainCalibration.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 SiPixelGainCalibration::encodeGain | ( | const float & | gain | ) | [private] |
Definition at line 154 of file SiPixelGainCalibration.cc.
References Exception, maxGain_, minGain_, and nBinsToUseForEncoding_.
Referenced by setData().
{ if(gain < minGain_ || gain > maxGain_ ) { throw cms::Exception("InsertFailure") << "[SiPixelGainCalibration::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 SiPixelGainCalibration::encodePed | ( | const float & | ped | ) | [private] |
Definition at line 167 of file SiPixelGainCalibration.cc.
References Exception, maxPed_, minPed_, and nBinsToUseForEncoding_.
Referenced by setData().
{ if(ped < minPed_ || ped > maxPed_ ) { throw cms::Exception("InsertFailure") << "[SiPixelGainCalibration::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 SiPixelGainCalibration::getDetIds | ( | std::vector< uint32_t > & | DetIds_ | ) | const |
Definition at line 87 of file SiPixelGainCalibration.cc.
References begin, end, indexes, and AlCaHLTBitMon_ParallelJobs::p.
{ // returns vector of DetIds in map SiPixelGainCalibration::RegistryIterator begin = indexes.begin(); SiPixelGainCalibration::RegistryIterator end = indexes.end(); for (SiPixelGainCalibration::RegistryIterator p=begin; p != end; ++p) { DetIds_.push_back(p->detid); } }
float SiPixelGainCalibration::getGain | ( | const int & | col, |
const int & | row, | ||
const Range & | range, | ||
const int & | nCols, | ||
bool & | isDead, | ||
bool & | isNoisy | ||
) | const |
Definition at line 139 of file SiPixelGainCalibration.cc.
References deadFlag_, decodeGain(), Exception, SiPixelGainCalibration::DecodingStructure::gain, noisyFlag_, and alignCSCRings::s.
{ int nRows = (range.second-range.first)/2 / nCols; const DecodingStructure & s = (const DecodingStructure & ) *(range.first+(col*nRows + row)*2); if (col >= nCols || row >= nRows){ throw cms::Exception("CorruptedData") << "[SiPixelGainCalibration::getPed] Pixel out of range: col " << col << " row " << row; } if ((s.gain & 0xFF) == deadFlag_) isDead = true; if ((s.gain & 0xFF) == noisyFlag_) isNoisy = true; return decodeGain(s.gain & 0xFF); }
double SiPixelGainCalibration::getGainHigh | ( | ) | const [inline] |
double SiPixelGainCalibration::getGainLow | ( | ) | const [inline] |
const int SiPixelGainCalibration::getNCols | ( | const uint32_t & | detID | ) | const |
Definition at line 58 of file SiPixelGainCalibration.cc.
References indexes, and AlCaHLTBitMon_ParallelJobs::p.
{ // get number of columns of DetId RegistryIterator p = std::lower_bound(indexes.begin(),indexes.end(),DetId,SiPixelGainCalibration::StrictWeakOrdering()); if (p==indexes.end()|| p->detid!=DetId) return 0; else return p->ncols; }
unsigned int SiPixelGainCalibration::getNumberOfRowsToAverageOver | ( | ) | const [inline] |
Definition at line 65 of file SiPixelGainCalibration.h.
References numberOfRowsToAverageOver_.
{ return numberOfRowsToAverageOver_; }
float SiPixelGainCalibration::getPed | ( | const int & | col, |
const int & | row, | ||
const Range & | range, | ||
const int & | nCols, | ||
bool & | isDead, | ||
bool & | isNoisy | ||
) | const |
Definition at line 124 of file SiPixelGainCalibration.cc.
References deadFlag_, decodePed(), Exception, noisyFlag_, SiPixelGainCalibration::DecodingStructure::ped, and alignCSCRings::s.
{ int nRows = (range.second-range.first)/2 / nCols; const DecodingStructure & s = (const DecodingStructure & ) *(range.first+(col*nRows + row)*2); if (col >= nCols || row >= nRows){ throw cms::Exception("CorruptedData") << "[SiPixelGainCalibration::getPed] Pixel out of range: col " << col << " row " << row; } if ((s.ped & 0xFF) == deadFlag_) isDead = true; if ((s.ped & 0xFF) == noisyFlag_) isNoisy = true; return decodePed(s.ped & 0xFF); }
double SiPixelGainCalibration::getPedHigh | ( | ) | const [inline] |
double SiPixelGainCalibration::getPedLow | ( | ) | const [inline] |
const SiPixelGainCalibration::Range SiPixelGainCalibration::getRange | ( | const uint32_t & | detID | ) | const |
Definition at line 67 of file SiPixelGainCalibration.cc.
References indexes, AlCaHLTBitMon_ParallelJobs::p, and v_pedestals.
{ // get SiPixelGainCalibration Range of DetId RegistryIterator p = std::lower_bound(indexes.begin(),indexes.end(),DetId,SiPixelGainCalibration::StrictWeakOrdering()); if (p==indexes.end()|| p->detid!=DetId) return SiPixelGainCalibration::Range(v_pedestals.end(),v_pedestals.end()); else return SiPixelGainCalibration::Range(v_pedestals.begin()+p->ibegin,v_pedestals.begin()+p->iend); }
const std::pair< const SiPixelGainCalibration::Range, const int > SiPixelGainCalibration::getRangeAndNCols | ( | const uint32_t & | detID | ) | const |
Definition at line 78 of file SiPixelGainCalibration.cc.
References indexes, AlCaHLTBitMon_ParallelJobs::p, and v_pedestals.
{ RegistryIterator p = std::lower_bound(indexes.begin(),indexes.end(),DetId,SiPixelGainCalibration::StrictWeakOrdering()); if (p==indexes.end()|| p->detid!=DetId) return std::make_pair(SiPixelGainCalibration::Range(v_pedestals.end(),v_pedestals.end()), 0); else return std::make_pair(SiPixelGainCalibration::Range(v_pedestals.begin()+p->ibegin,v_pedestals.begin()+p->iend), p->ncols); }
bool SiPixelGainCalibration::put | ( | const uint32_t & | detID, |
Range | input, | ||
const int & | nCols | ||
) |
Definition at line 39 of file SiPixelGainCalibration.cc.
References SiPixelGainCalibration::DetRegistry::detid, SiPixelGainCalibration::DetRegistry::ibegin, SiPixelGainCalibration::DetRegistry::iend, indexes, SiPixelGainCalibration::DetRegistry::ncols, AlCaHLTBitMon_ParallelJobs::p, sd, and v_pedestals.
{ // put in SiPixelGainCalibration of DetId Registry::iterator p = std::lower_bound(indexes.begin(),indexes.end(),DetId,SiPixelGainCalibration::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 SiPixelGainCalibration::setData | ( | float | ped, |
float | gain, | ||
std::vector< char > & | vped, | ||
bool | thisPixelIsDead = false , |
||
bool | thisPixelIsNoisy = false |
||
) |
Definition at line 96 of file SiPixelGainCalibration.cc.
References data, deadFlag_, encodeGain(), encodePed(), sistrip::extrainfo::gain_, and noisyFlag_.
Referenced by setDeadPixel(), and setNoisyPixel().
{ float theEncodedGain=0; float theEncodedPed=0; if(!isDeadPixel && !isNoisyPixel){ theEncodedGain = encodeGain(gain); theEncodedPed = encodePed (ped); } unsigned int ped_ = (static_cast<unsigned int>(theEncodedPed)) & 0xFF; unsigned int gain_ = (static_cast<unsigned int>(theEncodedGain)) & 0xFF; if (isDeadPixel) { ped_ = deadFlag_ & 0xFF; gain_ = deadFlag_ & 0xFF; } if (isNoisyPixel) { ped_ = noisyFlag_ & 0xFF; gain_ = noisyFlag_ & 0xFF; } unsigned int data = (ped_ << 8) | gain_ ; vped.resize(vped.size()+2); // insert in vector of char ::memcpy((void*)(&vped[vped.size()-2]),(void*)(&data),2); }
void SiPixelGainCalibration::setDeadPixel | ( | std::vector< char > & | vped | ) | [inline] |
Definition at line 74 of file SiPixelGainCalibration.h.
References setData().
{ setData(0, 0, /*dummy values, not used*/ vped, true , false ); }
void SiPixelGainCalibration::setNoisyPixel | ( | std::vector< char > & | vped | ) | [inline] |
Definition at line 75 of file SiPixelGainCalibration.h.
References setData().
{ setData(0, 0, /*dummy values, not used*/ vped, false , true ); }
unsigned int SiPixelGainCalibration::deadFlag_ [private] |
Definition at line 93 of file SiPixelGainCalibration.h.
Referenced by getGain(), getPed(), setData(), and SiPixelGainCalibration().
std::vector<DetRegistry> SiPixelGainCalibration::indexes [private] |
Definition at line 88 of file SiPixelGainCalibration.h.
Referenced by getDetIds(), getNCols(), getRange(), getRangeAndNCols(), and put().
float SiPixelGainCalibration::maxGain_ [private] |
Definition at line 89 of file SiPixelGainCalibration.h.
Referenced by decodeGain(), encodeGain(), and getGainHigh().
float SiPixelGainCalibration::maxPed_ [private] |
Definition at line 89 of file SiPixelGainCalibration.h.
Referenced by decodePed(), encodePed(), and getPedHigh().
float SiPixelGainCalibration::minGain_ [private] |
Definition at line 89 of file SiPixelGainCalibration.h.
Referenced by decodeGain(), encodeGain(), and getGainLow().
float SiPixelGainCalibration::minPed_ [private] |
Definition at line 89 of file SiPixelGainCalibration.h.
Referenced by decodePed(), encodePed(), and getPedLow().
unsigned int SiPixelGainCalibration::nBinsToUseForEncoding_ [private] |
Definition at line 92 of file SiPixelGainCalibration.h.
Referenced by decodeGain(), decodePed(), encodeGain(), and encodePed().
unsigned int SiPixelGainCalibration::noisyFlag_ [private] |
Definition at line 94 of file SiPixelGainCalibration.h.
unsigned int SiPixelGainCalibration::numberOfRowsToAverageOver_ [private] |
Definition at line 91 of file SiPixelGainCalibration.h.
Referenced by getNumberOfRowsToAverageOver().
std::vector<char> SiPixelGainCalibration::v_pedestals [private] |
Definition at line 87 of file SiPixelGainCalibration.h.
Referenced by getRange(), getRangeAndNCols(), and put().