CMS 3D CMS Logo

SiPixelGainCalibration Class Reference

Description: Gain calibration object for the Silicon Pixel detector. More...

#include <CondFormats/SiPixelObjects/src/SiPixelGainCalibration.cc>

List of all members.

Public Types

typedef std::vector< char >
::const_iterator 
ContainerIterator
typedef std::pair
< ContainerIterator,
ContainerIterator
Range
typedef std::vector< DetRegistryRegistry
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) 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) 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)
void setDeadPixel (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< DetRegistryindexes
float maxGain_
float maxPed_
float minGain_
float minPed_
unsigned int nBinsToUseForEncoding_
unsigned int numberOfRowsToAverageOver_
std::vector< char > v_pedestals

Classes

struct  DecodingStructure
struct  DetRegistry
class  StrictWeakOrdering


Detailed Description

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.


Member Typedef Documentation

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.


Constructor & Destructor Documentation

SiPixelGainCalibration::SiPixelGainCalibration (  ) 

Definition at line 7 of file SiPixelGainCalibration.cc.

References deadFlag_, and Exception.

00007                                                :
00008   minPed_(0.),
00009   maxPed_(255.),
00010   minGain_(0.),
00011   maxGain_(255.),
00012   numberOfRowsToAverageOver_(1),
00013   nBinsToUseForEncoding_(254),
00014   deadFlag_(255)
00015 {
00016    if (deadFlag_ > 0xFF)
00017       throw cms::Exception("GainCalibration Payload configuration error")
00018          << "[SiPixelGainCalibration::SiPixelGainCalibration] Dead flag was set to " << deadFlag_ << ", and it must be set less than or equal to 255";
00019 }
//

SiPixelGainCalibration::SiPixelGainCalibration ( float  minPed,
float  maxPed,
float  minGain,
float  maxGain 
)

Definition at line 21 of file SiPixelGainCalibration.cc.

References deadFlag_, and Exception.

00021                                                                                                        :
00022   minPed_(minPed),
00023   maxPed_(maxPed),
00024   minGain_(minGain),
00025   maxGain_(maxGain),
00026   numberOfRowsToAverageOver_(1),
00027   nBinsToUseForEncoding_(254),
00028   deadFlag_(255)
00029 {
00030    if (deadFlag_ > 0xFF)
00031       throw cms::Exception("GainCalibration Payload configuration error")
00032          << "[SiPixelGainCalibration::SiPixelGainCalibration] Dead flag was set to " << deadFlag_ << ", and it must be set less than or equal to 255";
00033 }

virtual SiPixelGainCalibration::~SiPixelGainCalibration (  )  [inline, virtual]

Definition at line 57 of file SiPixelGainCalibration.h.

00057 {};


Member Function Documentation

float SiPixelGainCalibration::decodeGain ( unsigned int  gain  )  const [private]

Definition at line 172 of file SiPixelGainCalibration.cc.

References maxGain_, minGain_, and nBinsToUseForEncoding_.

Referenced by getGain().

00172                                                                   {
00173 
00174   double precision = (maxGain_-minGain_)/static_cast<float>(nBinsToUseForEncoding_);
00175   float decodedGain = (float)(gain*precision + minGain_);
00176   return decodedGain;
00177 
00178 }

float SiPixelGainCalibration::decodePed ( unsigned int  ped  )  const [private]

Definition at line 164 of file SiPixelGainCalibration.cc.

References maxPed_, minPed_, and nBinsToUseForEncoding_.

Referenced by getPed().

00164                                                                 {
00165 
00166   double precision = (maxPed_-minPed_)/static_cast<float>(nBinsToUseForEncoding_);
00167   float decodedPed = (float)(ped*precision + minPed_);
00168   return decodedPed;
00169 
00170 }

float SiPixelGainCalibration::encodeGain ( const float &  gain  )  [private]

Definition at line 138 of file SiPixelGainCalibration.cc.

References Exception, maxGain_, minGain_, and nBinsToUseForEncoding_.

Referenced by setData().

00138                                                             {
00139   
00140   if(gain < minGain_ || gain > maxGain_ ) {
00141     throw cms::Exception("InsertFailure")
00142       << "[SiPixelGainCalibration::encodeGain] Trying to encode gain (" << gain << ") out of range [" << minGain_ << "," << maxGain_ << "]\n";
00143   } else {
00144     double precision   = (maxGain_-minGain_)/static_cast<float>(nBinsToUseForEncoding_);
00145     float  encodedGain = (float)((gain-minGain_)/precision);
00146     return encodedGain;
00147   }
00148 
00149 }

float SiPixelGainCalibration::encodePed ( const float &  ped  )  [private]

Definition at line 151 of file SiPixelGainCalibration.cc.

References Exception, maxPed_, minPed_, and nBinsToUseForEncoding_.

Referenced by setData().

00151                                                           {
00152 
00153   if(ped < minPed_ || ped > maxPed_ ) {
00154     throw cms::Exception("InsertFailure")
00155       << "[SiPixelGainCalibration::encodePed] Trying to encode pedestal (" << ped << ") out of range [" << minPed_ << "," << maxPed_ << "]\n";
00156   } else {
00157     double precision   = (maxPed_-minPed_)/static_cast<float>(nBinsToUseForEncoding_);
00158     float  encodedPed = (float)((ped-minPed_)/precision);
00159     return encodedPed;
00160   }
00161 
00162 }

void SiPixelGainCalibration::getDetIds ( std::vector< uint32_t > &  DetIds_  )  const

Definition at line 83 of file SiPixelGainCalibration.cc.

References begin, end, indexes, and p.

00083                                                                          {
00084   // returns vector of DetIds in map
00085   SiPixelGainCalibration::RegistryIterator begin = indexes.begin();
00086   SiPixelGainCalibration::RegistryIterator end   = indexes.end();
00087   for (SiPixelGainCalibration::RegistryIterator p=begin; p != end; ++p) {
00088     DetIds_.push_back(p->detid);
00089   }
00090 }

float SiPixelGainCalibration::getGain ( const int col,
const int row,
const Range range,
const int nCols,
bool isDead 
) const

Definition at line 125 of file SiPixelGainCalibration.cc.

References deadFlag_, decodeGain(), Exception, SiPixelGainCalibration::DecodingStructure::gain, and s.

00125                                                                                                                               {
00126 
00127   int nRows = (range.second-range.first)/2 / nCols;
00128   const DecodingStructure & s = (const DecodingStructure & ) *(range.first+(col*nRows + row)*2);
00129   if (col >= nCols || row >= nRows){
00130     throw cms::Exception("CorruptedData")
00131       << "[SiPixelGainCalibration::getPed] Pixel out of range: col " << col << " row " << row;
00132   }  
00133   if ((s.gain & 0xFF) == deadFlag_)
00134      isDead = true;
00135   return decodeGain(s.gain & 0xFF);
00136 }

const int SiPixelGainCalibration::getNCols ( const uint32_t &  detID  )  const

Definition at line 54 of file SiPixelGainCalibration.cc.

References indexes, and p.

00054                                                                       {
00055   // get number of columns of DetId
00056   RegistryIterator p = std::lower_bound(indexes.begin(),indexes.end(),DetId,SiPixelGainCalibration::StrictWeakOrdering());
00057   if (p==indexes.end()|| p->detid!=DetId) 
00058     return 0;
00059   else
00060     return p->ncols; 
00061 }

unsigned int SiPixelGainCalibration::getNumberOfRowsToAverageOver (  )  const [inline]

Definition at line 65 of file SiPixelGainCalibration.h.

References numberOfRowsToAverageOver_.

00065 { return numberOfRowsToAverageOver_; }

float SiPixelGainCalibration::getPed ( const int col,
const int row,
const Range range,
const int nCols,
bool isDead 
) const

Definition at line 112 of file SiPixelGainCalibration.cc.

References deadFlag_, decodePed(), Exception, SiPixelGainCalibration::DecodingStructure::ped, and s.

00112                                                                                                                              {
00113 
00114   int nRows = (range.second-range.first)/2 / nCols;
00115   const DecodingStructure & s = (const DecodingStructure & ) *(range.first+(col*nRows + row)*2);
00116   if (col >= nCols || row >= nRows){
00117     throw cms::Exception("CorruptedData")
00118       << "[SiPixelGainCalibration::getPed] Pixel out of range: col " << col << " row " << row;
00119   }  
00120   if ((s.ped & 0xFF) == deadFlag_)
00121      isDead = true;
00122   return decodePed(s.ped & 0xFF);  
00123 }

const SiPixelGainCalibration::Range SiPixelGainCalibration::getRange ( const uint32_t &  detID  )  const

Definition at line 63 of file SiPixelGainCalibration.cc.

References indexes, p, and v_pedestals.

00063                                                                                               {
00064   // get SiPixelGainCalibration Range of DetId
00065   
00066   RegistryIterator p = std::lower_bound(indexes.begin(),indexes.end(),DetId,SiPixelGainCalibration::StrictWeakOrdering());
00067   if (p==indexes.end()|| p->detid!=DetId) 
00068     return SiPixelGainCalibration::Range(v_pedestals.end(),v_pedestals.end()); 
00069   else 
00070     return SiPixelGainCalibration::Range(v_pedestals.begin()+p->ibegin,v_pedestals.begin()+p->iend);
00071 }

const std::pair< const SiPixelGainCalibration::Range, const int > SiPixelGainCalibration::getRangeAndNCols ( const uint32_t &  detID  )  const

Definition at line 74 of file SiPixelGainCalibration.cc.

References indexes, p, and v_pedestals.

00074                                                                     {
00075   RegistryIterator p = std::lower_bound(indexes.begin(),indexes.end(),DetId,SiPixelGainCalibration::StrictWeakOrdering());
00076   if (p==indexes.end()|| p->detid!=DetId) 
00077     return std::make_pair(SiPixelGainCalibration::Range(v_pedestals.end(),v_pedestals.end()), 0); 
00078   else 
00079     return std::make_pair(SiPixelGainCalibration::Range(v_pedestals.begin()+p->ibegin,v_pedestals.begin()+p->iend), p->ncols);
00080 }

bool SiPixelGainCalibration::put ( const uint32_t &  detID,
Range  input,
const int nCols 
)

Definition at line 35 of file SiPixelGainCalibration.cc.

References SiPixelGainCalibration::DetRegistry::detid, SiPixelGainCalibration::DetRegistry::ibegin, SiPixelGainCalibration::DetRegistry::iend, indexes, SiPixelGainCalibration::DetRegistry::ncols, p, and v_pedestals.

Referenced by SiPixelFakeGainESSource::produce().

00035                                                                                      {
00036   // put in SiPixelGainCalibration of DetId
00037 
00038   Registry::iterator p = std::lower_bound(indexes.begin(),indexes.end(),DetId,SiPixelGainCalibration::StrictWeakOrdering());
00039   if (p!=indexes.end() && p->detid==DetId)
00040     return false;
00041   
00042   size_t sd= input.second-input.first;
00043   DetRegistry detregistry;
00044   detregistry.detid=DetId;
00045   detregistry.ncols=nCols;
00046   detregistry.ibegin=v_pedestals.size();
00047   detregistry.iend=v_pedestals.size()+sd;
00048   indexes.insert(p,detregistry);
00049 
00050   v_pedestals.insert(v_pedestals.end(),input.first,input.second);
00051   return true;
00052 }

void SiPixelGainCalibration::setData ( float  ped,
float  gain,
std::vector< char > &  vped,
bool  thisPixelIsDead = false 
)

Definition at line 92 of file SiPixelGainCalibration.cc.

References data, deadFlag_, encodeGain(), encodePed(), and sistrip::extrainfo::gain_.

Referenced by SiPixelFakeGainESSource::produce(), and setDeadPixel().

00092                                                                                                   {
00093   
00094   float theEncodedGain  = encodeGain(gain);
00095   float theEncodedPed   = encodePed (ped);
00096 
00097   unsigned int ped_   = (static_cast<unsigned int>(theEncodedPed))  & 0xFF; 
00098   unsigned int gain_  = (static_cast<unsigned int>(theEncodedGain)) & 0xFF;
00099 
00100   if (isDeadPixel)
00101   {
00102      ped_  = deadFlag_;
00103      gain_ = deadFlag_;
00104   }
00105 
00106   unsigned int data = (ped_ << 8) | gain_ ;
00107   vped.resize(vped.size()+2);
00108   // insert in vector of char
00109   ::memcpy((void*)(&vped[vped.size()-2]),(void*)(&data),2);
00110 }

void SiPixelGainCalibration::setDeadPixel ( std::vector< char > &  vped  )  [inline]

Definition at line 70 of file SiPixelGainCalibration.h.

References setData().

00070 { setData(0, 0, /*dummy values, not used*/ vped,  true ); }


Member Data Documentation

unsigned int SiPixelGainCalibration::deadFlag_ [private]

Definition at line 88 of file SiPixelGainCalibration.h.

Referenced by getGain(), getPed(), setData(), and SiPixelGainCalibration().

std::vector<DetRegistry> SiPixelGainCalibration::indexes [private]

Definition at line 83 of file SiPixelGainCalibration.h.

Referenced by getDetIds(), getNCols(), getRange(), getRangeAndNCols(), and put().

float SiPixelGainCalibration::maxGain_ [private]

Definition at line 84 of file SiPixelGainCalibration.h.

Referenced by decodeGain(), and encodeGain().

float SiPixelGainCalibration::maxPed_ [private]

Definition at line 84 of file SiPixelGainCalibration.h.

Referenced by decodePed(), and encodePed().

float SiPixelGainCalibration::minGain_ [private]

Definition at line 84 of file SiPixelGainCalibration.h.

Referenced by decodeGain(), and encodeGain().

float SiPixelGainCalibration::minPed_ [private]

Definition at line 84 of file SiPixelGainCalibration.h.

Referenced by decodePed(), and encodePed().

unsigned int SiPixelGainCalibration::nBinsToUseForEncoding_ [private]

Definition at line 87 of file SiPixelGainCalibration.h.

Referenced by decodeGain(), decodePed(), encodeGain(), and encodePed().

unsigned int SiPixelGainCalibration::numberOfRowsToAverageOver_ [private]

Definition at line 86 of file SiPixelGainCalibration.h.

Referenced by getNumberOfRowsToAverageOver().

std::vector<char> SiPixelGainCalibration::v_pedestals [private]

Definition at line 82 of file SiPixelGainCalibration.h.

Referenced by getRange(), getRangeAndNCols(), and put().


The documentation for this class was generated from the following files:
Generated on Tue Jun 9 18:31:59 2009 for CMSSW by  doxygen 1.5.4