CMS 3D CMS Logo

SiPixelGainCalibrationOffline Class Reference

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

#include <CondFormats/SiPixelObjects/src/SiPixelGainCalibrationOffline.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 &isDeadColumn) 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 setDataGain (float gain, const int &nRows, std::vector< char > &vped, bool thisColumnIsDead=false)
void setDataPedestal (float pedestal, std::vector< char > &vped, bool thisPixelIsDead=false)
void setDeadColumn (const int &nRows, std::vector< char > &vped)
void setDeadPixel (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< 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.

Stores pedestal at pixel granularity, gain at column granularity.

Implementation: <Notes on="" implementation>="">

Definition at line 27 of file SiPixelGainCalibrationOffline.h.


Member Typedef Documentation

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.


Constructor & Destructor Documentation

SiPixelGainCalibrationOffline::SiPixelGainCalibrationOffline (  ) 

Definition at line 7 of file SiPixelGainCalibrationOffline.cc.

References deadFlag_, and Exception.

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

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

Definition at line 21 of file SiPixelGainCalibrationOffline.cc.

References deadFlag_, and Exception.

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

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

Definition at line 55 of file SiPixelGainCalibrationOffline.h.

00055 {};


Member Function Documentation

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

Definition at line 210 of file SiPixelGainCalibrationOffline.cc.

References maxGain_, minGain_, and nBinsToUseForEncoding_.

Referenced by getGain().

00210                                                                          {
00211 
00212   double precision = (maxGain_-minGain_)/static_cast<float>(nBinsToUseForEncoding_);
00213   float decodedGain = (float)(gain*precision + minGain_);
00214   return decodedGain;
00215 }

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

Definition at line 202 of file SiPixelGainCalibrationOffline.cc.

References maxPed_, minPed_, and nBinsToUseForEncoding_.

Referenced by getPed().

00202                                                                        {
00203 
00204   double precision = (maxPed_-minPed_)/static_cast<float>(nBinsToUseForEncoding_);
00205   float decodedPed = (float)(ped*precision + minPed_);
00206   return decodedPed;
00207 
00208 }

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

Definition at line 176 of file SiPixelGainCalibrationOffline.cc.

References Exception, maxGain_, minGain_, and nBinsToUseForEncoding_.

Referenced by setDataGain().

00176                                                                    {
00177   
00178   if(gain < minGain_ || gain > maxGain_ ) {
00179     throw cms::Exception("InsertFailure")
00180       << "[SiPixelGainCalibrationOffline::encodeGain] Trying to encode gain (" << gain << ") out of range [" << minGain_ << "," << maxGain_ << "]\n";
00181   } else {
00182     double precision   = (maxGain_-minGain_)/static_cast<float>(nBinsToUseForEncoding_);
00183     float  encodedGain = (float)((gain-minGain_)/precision);
00184     return encodedGain;
00185   }
00186 
00187 }

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

Definition at line 189 of file SiPixelGainCalibrationOffline.cc.

References Exception, maxPed_, minPed_, and nBinsToUseForEncoding_.

Referenced by setDataPedestal().

00189                                                                  {
00190 
00191   if(ped < minPed_ || ped > maxPed_ ) {
00192     throw cms::Exception("InsertFailure")
00193       << "[SiPixelGainCalibrationOffline::encodePed] Trying to encode pedestal (" << ped << ") out of range [" << minPed_ << "," << maxPed_ << "]\n";
00194   } else {
00195     double precision   = (maxPed_-minPed_)/static_cast<float>(nBinsToUseForEncoding_);
00196     float  encodedPed = (float)((ped-minPed_)/precision);
00197     return encodedPed;
00198   }
00199 
00200 }

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

Definition at line 83 of file SiPixelGainCalibrationOffline.cc.

References begin, end, indexes, and p.

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

float SiPixelGainCalibrationOffline::getGain ( const int col,
const int row,
const Range range,
const int nCols,
bool isDeadColumn 
) const

Definition at line 155 of file SiPixelGainCalibrationOffline.cc.

References SiPixelGainCalibrationOffline::DecodingStructure::datum, deadFlag_, decodeGain(), Exception, numberOfRowsToAverageOver_, and s.

00155                                                                                                                                            {
00156 
00157   unsigned int lengthOfColumnData = (range.second-range.first)/nCols;
00158   //determine what row averaged range we are in (i.e. ROC 1 or ROC 2)
00159   unsigned int lengthOfAveragedDataInEachColumn = numberOfRowsToAverageOver_ + 1;
00160   unsigned int numberOfAveragedDataBlocksToSkip = row / numberOfRowsToAverageOver_;
00161 
00162   // gain average is stored in the last location of current row averaged column data block
00163   const DecodingStructure & s = (const DecodingStructure & ) *(range.first+(col)*(lengthOfColumnData) + ( (numberOfAveragedDataBlocksToSkip+1) * lengthOfAveragedDataInEachColumn) - 1);
00164 
00165   if ((s.datum & 0xFF) == deadFlag_)
00166      isDeadColumn = true;
00167 
00168   int maxRow = lengthOfColumnData - (lengthOfColumnData % numberOfRowsToAverageOver_) - 1;
00169   if (col >= nCols || row > maxRow){
00170     throw cms::Exception("CorruptedData")
00171       << "[SiPixelGainCalibrationOffline::getPed] Pixel out of range: col " << col;
00172   }  
00173   return decodeGain(s.datum & 0xFF);
00174 }

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

Definition at line 54 of file SiPixelGainCalibrationOffline.cc.

References indexes, and p.

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

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

Definition at line 67 of file SiPixelGainCalibrationOffline.h.

References numberOfRowsToAverageOver_.

00067 { return numberOfRowsToAverageOver_; }

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

Definition at line 133 of file SiPixelGainCalibrationOffline.cc.

References SiPixelGainCalibrationOffline::DecodingStructure::datum, deadFlag_, decodePed(), Exception, numberOfRowsToAverageOver_, and s.

00133                                                                                                                                     {
00134 
00135   unsigned int lengthOfColumnData = (range.second-range.first)/nCols;
00136   //determine what row averaged range we are in (i.e. ROC 1 or ROC 2)
00137   unsigned int lengthOfAveragedDataInEachColumn = numberOfRowsToAverageOver_ + 1;
00138   unsigned int numberOfAveragedDataBlocksToSkip = row / numberOfRowsToAverageOver_;
00139   unsigned int offSetInCorrectDataBlock         = row % numberOfRowsToAverageOver_;
00140 
00141   const DecodingStructure & s = (const DecodingStructure & ) *(range.first + col*(lengthOfColumnData) + (numberOfAveragedDataBlocksToSkip * lengthOfAveragedDataInEachColumn) + offSetInCorrectDataBlock);
00142 
00143   int maxRow = lengthOfColumnData - (lengthOfColumnData % numberOfRowsToAverageOver_) - 1;
00144   if (col >= nCols || row > maxRow){
00145     throw cms::Exception("CorruptedData")
00146       << "[SiPixelGainCalibrationOffline::getPed] Pixel out of range: col " << col << " row " << row;
00147   }  
00148 
00149   if ((s.datum & 0xFF) == deadFlag_)
00150      isDead = true;
00151 
00152   return decodePed(s.datum & 0xFF);  
00153 }

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

Definition at line 63 of file SiPixelGainCalibrationOffline.cc.

References indexes, p, and v_pedestals.

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

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

Definition at line 74 of file SiPixelGainCalibrationOffline.cc.

References indexes, p, and v_pedestals.

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

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

Definition at line 35 of file SiPixelGainCalibrationOffline.cc.

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

Referenced by SiPixelFakeGainOfflineESSource::produce().

00035                                                                                             {
00036   // put in SiPixelGainCalibrationOffline of DetId
00037 
00038   Registry::iterator p = std::lower_bound(indexes.begin(),indexes.end(),DetId,SiPixelGainCalibrationOffline::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 SiPixelGainCalibrationOffline::setDataGain ( float  gain,
const int nRows,
std::vector< char > &  vped,
bool  thisColumnIsDead = false 
)

Definition at line 92 of file SiPixelGainCalibrationOffline.cc.

References deadFlag_, encodeGain(), Exception, sistrip::extrainfo::gain_, and numberOfRowsToAverageOver_.

Referenced by SiPixelFakeGainOfflineESSource::produce(), and setDeadColumn().

00092                                                                                                                          {
00093   
00094   float theEncodedGain  = encodeGain(gain);
00095 
00096   unsigned int gain_  = (static_cast<unsigned int>(theEncodedGain)) & 0xFF;
00097 
00098   // if this whole column is dead, set a char based dead flag in the blob.
00099   if (thisColumnIsDead)
00100      gain_ = deadFlag_ & 0xFF;
00101 
00102   vped.resize(vped.size()+1);
00103   //check to make sure the column is being placed in the right place in the blob
00104   if (nRows != (int)numberOfRowsToAverageOver_)
00105   {
00106     throw cms::Exception("GainCalibration Payload configuration error")
00107       << "[SiPixelGainCalibrationOffline::setDataGain] You are setting a gain averaged over nRows = " << nRows << " where this payload is set ONLY to average over " << numberOfRowsToAverageOver_ << " nRows";
00108   }
00109 
00110   if (vped.size() % (nRows + 1) != 0) 
00111   {
00112     throw cms::Exception("FillError")
00113       << "[SiPixelGainCalibrationOffline::setDataGain] Column gain average (OR SETTING AN ENTIRE COLUMN DEAD) must be filled after the pedestal for each row has been added. An additional source of this error would be setting a pixel dead AND setting its pedestal";
00114   }  
00115   // insert in vector of char
00116   ::memcpy((void*)(&vped[vped.size()-1]),(void*)(&gain_),1);
00117 }

void SiPixelGainCalibrationOffline::setDataPedestal ( float  pedestal,
std::vector< char > &  vped,
bool  thisPixelIsDead = false 
)

Definition at line 119 of file SiPixelGainCalibrationOffline.cc.

References deadFlag_, and encodePed().

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

00119                                                                                                                {
00120 
00121   float theEncodedPedestal  = encodePed(pedestal);
00122 
00123   unsigned int ped_  = (static_cast<unsigned int>(theEncodedPedestal)) & 0xFF;
00124 
00125   if (thisPixelIsDead)
00126      ped_ = deadFlag_ & 0xFF;
00127 
00128   vped.resize(vped.size()+1);
00129   // insert in vector of char
00130   ::memcpy((void*)(&vped[vped.size()-1]),(void*)(&ped_),1);
00131 }

void SiPixelGainCalibrationOffline::setDeadColumn ( const int nRows,
std::vector< char > &  vped 
) [inline]

Definition at line 71 of file SiPixelGainCalibrationOffline.h.

References setDataGain().

00071 { setDataGain(0 /*dummy value, not used*/, nRows, vped,  true ); }

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

Definition at line 70 of file SiPixelGainCalibrationOffline.h.

References setDataPedestal().

00070 { setDataPedestal(0 /*dummy value, not used*/,    vped,  true ); }


Member Data Documentation

unsigned int SiPixelGainCalibrationOffline::deadFlag_ [private]

Definition at line 91 of file SiPixelGainCalibrationOffline.h.

Referenced by getGain(), getPed(), setDataGain(), setDataPedestal(), and SiPixelGainCalibrationOffline().

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

Definition at line 86 of file SiPixelGainCalibrationOffline.h.

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

float SiPixelGainCalibrationOffline::maxGain_ [private]

Definition at line 87 of file SiPixelGainCalibrationOffline.h.

Referenced by decodeGain(), and encodeGain().

float SiPixelGainCalibrationOffline::maxPed_ [private]

Definition at line 87 of file SiPixelGainCalibrationOffline.h.

Referenced by decodePed(), and encodePed().

float SiPixelGainCalibrationOffline::minGain_ [private]

Definition at line 87 of file SiPixelGainCalibrationOffline.h.

Referenced by decodeGain(), and encodeGain().

float SiPixelGainCalibrationOffline::minPed_ [private]

Definition at line 87 of file SiPixelGainCalibrationOffline.h.

Referenced by decodePed(), and encodePed().

unsigned int SiPixelGainCalibrationOffline::nBinsToUseForEncoding_ [private]

Definition at line 90 of file SiPixelGainCalibrationOffline.h.

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

unsigned int SiPixelGainCalibrationOffline::numberOfRowsToAverageOver_ [private]

Definition at line 89 of file SiPixelGainCalibrationOffline.h.

Referenced by getGain(), getNumberOfRowsToAverageOver(), getPed(), and setDataGain().

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

Definition at line 85 of file SiPixelGainCalibrationOffline.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