CMS 3D CMS Logo

SiPixelGainCalibrationForHLT Class Reference

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

#include <CondFormats/SiPixelObjects/src/SiPixelGainCalibrationForHLT.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 &isDeadColumn) 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 thisColumnIsDead=false)
void setDeadColumn (const int &nRows, std::vector< char > &vped)
 SiPixelGainCalibrationForHLT (float minPed, float maxPed, float minGain, float maxGain)
 SiPixelGainCalibrationForHLT ()
virtual ~SiPixelGainCalibrationForHLT ()

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 for use at HLT.

Stores only average gain and average pedestal per column.

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

Definition at line 27 of file SiPixelGainCalibrationForHLT.h.


Member Typedef Documentation

typedef std::vector<char>::const_iterator SiPixelGainCalibrationForHLT::ContainerIterator

Definition at line 48 of file SiPixelGainCalibrationForHLT.h.

typedef std::pair<ContainerIterator, ContainerIterator> SiPixelGainCalibrationForHLT::Range

Definition at line 49 of file SiPixelGainCalibrationForHLT.h.

typedef std::vector<DetRegistry> SiPixelGainCalibrationForHLT::Registry

Definition at line 50 of file SiPixelGainCalibrationForHLT.h.

typedef Registry::const_iterator SiPixelGainCalibrationForHLT::RegistryIterator

Definition at line 51 of file SiPixelGainCalibrationForHLT.h.


Constructor & Destructor Documentation

SiPixelGainCalibrationForHLT::SiPixelGainCalibrationForHLT (  ) 

Definition at line 7 of file SiPixelGainCalibrationForHLT.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          << "[SiPixelGainCalibrationHLT::SiPixelGainCalibrationHLT] Dead flag was set to " << deadFlag_ << ", and it must be set less than or equal to 255";
00019 }
//

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

Definition at line 21 of file SiPixelGainCalibrationForHLT.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          << "[SiPixelGainCalibrationHLT::SiPixelGainCalibrationHLT] Dead flag was set to " << deadFlag_ << ", and it must be set less than or equal to 255";
00033 }

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

Definition at line 56 of file SiPixelGainCalibrationForHLT.h.

00056 {};


Member Function Documentation

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

Definition at line 193 of file SiPixelGainCalibrationForHLT.cc.

References maxGain_, minGain_, and nBinsToUseForEncoding_.

Referenced by getGain().

00193                                                                         {
00194 
00195   double precision = (maxGain_-minGain_)/static_cast<float>(nBinsToUseForEncoding_);
00196   float decodedGain = (float)(gain*precision + minGain_);
00197   return decodedGain;
00198 
00199 }

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

Definition at line 185 of file SiPixelGainCalibrationForHLT.cc.

References maxPed_, minPed_, and nBinsToUseForEncoding_.

Referenced by getPed().

00185                                                                       {
00186 
00187   double precision = (maxPed_-minPed_)/static_cast<float>(nBinsToUseForEncoding_);
00188   float decodedPed = (float)(ped*precision + minPed_);
00189   return decodedPed;
00190 
00191 }

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

Definition at line 159 of file SiPixelGainCalibrationForHLT.cc.

References Exception, maxGain_, minGain_, and nBinsToUseForEncoding_.

Referenced by setData().

00159                                                                   {
00160   
00161   if(gain < minGain_ || gain > maxGain_ ) {
00162     throw cms::Exception("InsertFailure")
00163       << "[SiPixelGainCalibrationForHLT::encodeGain] Trying to encode gain (" << gain << ") out of range [" << minGain_ << "," << maxGain_ << "]\n";
00164   } else {
00165     double precision   = (maxGain_-minGain_)/static_cast<float>(nBinsToUseForEncoding_);
00166     float  encodedGain = (float)((gain-minGain_)/precision);
00167     return encodedGain;
00168   }
00169 
00170 }

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

Definition at line 172 of file SiPixelGainCalibrationForHLT.cc.

References Exception, maxPed_, minPed_, and nBinsToUseForEncoding_.

Referenced by setData().

00172                                                                 {
00173 
00174   if(ped < minPed_ || ped > maxPed_ ) {
00175     throw cms::Exception("InsertFailure")
00176       << "[SiPixelGainCalibrationForHLT::encodePed] Trying to encode pedestal (" << ped << ") out of range [" << minPed_ << "," << maxPed_ << "]\n";
00177   } else {
00178     double precision   = (maxPed_-minPed_)/static_cast<float>(nBinsToUseForEncoding_);
00179     float  encodedPed = (float)((ped-minPed_)/precision);
00180     return encodedPed;
00181   }
00182 
00183 }

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

Definition at line 84 of file SiPixelGainCalibrationForHLT.cc.

References begin, end, indexes, and p.

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

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

Definition at line 136 of file SiPixelGainCalibrationForHLT.cc.

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

00136                                                                                                                                           {
00137 
00138   // determine what averaged data block we are in (there should be 1 or 2 of these depending on if plaquette is 1 by X or 2 by X
00139   unsigned int lengthOfColumnData  = (range.second-range.first)/nCols;
00140   unsigned int lengthOfAveragedDataInEachColumn = 2;  // we always only have two values per column averaged block 
00141   unsigned int numberOfDataBlocksToSkip = row / numberOfRowsToAverageOver_;
00142 
00143   const DecodingStructure & s = (const DecodingStructure & ) *(range.first+col*lengthOfColumnData + lengthOfAveragedDataInEachColumn*numberOfDataBlocksToSkip);
00144 
00145   if ((s.gain & 0xFF) == deadFlag_)
00146   {
00147      isDeadColumn = true;
00148   }
00149 
00150   int maxRow = (lengthOfColumnData/lengthOfAveragedDataInEachColumn)*numberOfRowsToAverageOver_ - 1;
00151   if (col >= nCols || row > maxRow){
00152     throw cms::Exception("CorruptedData")
00153       << "[SiPixelGainCalibrationForHLT::getGain] Pixel out of range: col " << col << " row: " << row;
00154   }  
00155   return decodeGain(s.gain & 0xFF);  
00156 
00157 }

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

Definition at line 54 of file SiPixelGainCalibrationForHLT.cc.

References indexes, and p.

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

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

Definition at line 64 of file SiPixelGainCalibrationForHLT.h.

References numberOfRowsToAverageOver_.

00064 { return numberOfRowsToAverageOver_; }

float SiPixelGainCalibrationForHLT::getPed ( const int col,
const int row,
const Range range,
const int nCols,
bool isDeadColumn 
) const

Definition at line 113 of file SiPixelGainCalibrationForHLT.cc.

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

00113                                                                                                                                          {
00114    // TODO MERGE THIS FUNCTION WITH GET GAIN, then provide wrappers
00115 
00116   // determine what averaged data block we are in (there should be 1 or 2 of these depending on if plaquette is 1 by X or 2 by X
00117   unsigned int lengthOfColumnData  = (range.second-range.first)/nCols;
00118   unsigned int lengthOfAveragedDataInEachColumn = 2;  // we always only have two values per column averaged block 
00119   unsigned int numberOfDataBlocksToSkip = row / numberOfRowsToAverageOver_;
00120 
00121   const DecodingStructure & s = (const DecodingStructure & ) *(range.first+col*lengthOfColumnData + lengthOfAveragedDataInEachColumn*numberOfDataBlocksToSkip);
00122 
00123   if ((s.ped & 0xFF) == deadFlag_)
00124   {
00125      isDeadColumn = true;
00126   }
00127 
00128   int maxRow = (lengthOfColumnData/lengthOfAveragedDataInEachColumn)*numberOfRowsToAverageOver_ - 1;
00129   if (col >= nCols || row > maxRow){
00130     throw cms::Exception("CorruptedData")
00131       << "[SiPixelGainCalibrationForHLT::getPed] Pixel out of range: col " << col << " row: " << row;
00132   }  
00133   return decodePed(s.ped & 0xFF);  
00134 }

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

Definition at line 65 of file SiPixelGainCalibrationForHLT.cc.

References indexes, p, and v_pedestals.

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

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

Definition at line 76 of file SiPixelGainCalibrationForHLT.cc.

References indexes, p, and v_pedestals.

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

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

Definition at line 35 of file SiPixelGainCalibrationForHLT.cc.

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

Referenced by SiPixelFakeGainForHLTESSource::produce().

00035                                                                                            {
00036   // put in SiPixelGainCalibrationForHLT of DetId
00037 
00038   Registry::iterator p = std::lower_bound(indexes.begin(),indexes.end(),DetId,SiPixelGainCalibrationForHLT::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.ibegin=v_pedestals.size();
00046   detregistry.iend=v_pedestals.size()+sd;
00047   detregistry.ncols=nCols;
00048   indexes.insert(p,detregistry);
00049 
00050   v_pedestals.insert(v_pedestals.end(),input.first,input.second);
00051   return true;
00052 }

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

Definition at line 93 of file SiPixelGainCalibrationForHLT.cc.

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

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

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

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

Definition at line 68 of file SiPixelGainCalibrationForHLT.h.

References setData().

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


Member Data Documentation

unsigned int SiPixelGainCalibrationForHLT::deadFlag_ [private]

Definition at line 86 of file SiPixelGainCalibrationForHLT.h.

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

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

Definition at line 81 of file SiPixelGainCalibrationForHLT.h.

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

float SiPixelGainCalibrationForHLT::maxGain_ [private]

Definition at line 82 of file SiPixelGainCalibrationForHLT.h.

Referenced by decodeGain(), and encodeGain().

float SiPixelGainCalibrationForHLT::maxPed_ [private]

Definition at line 82 of file SiPixelGainCalibrationForHLT.h.

Referenced by decodePed(), and encodePed().

float SiPixelGainCalibrationForHLT::minGain_ [private]

Definition at line 82 of file SiPixelGainCalibrationForHLT.h.

Referenced by decodeGain(), and encodeGain().

float SiPixelGainCalibrationForHLT::minPed_ [private]

Definition at line 82 of file SiPixelGainCalibrationForHLT.h.

Referenced by decodePed(), and encodePed().

unsigned int SiPixelGainCalibrationForHLT::nBinsToUseForEncoding_ [private]

Definition at line 85 of file SiPixelGainCalibrationForHLT.h.

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

unsigned int SiPixelGainCalibrationForHLT::numberOfRowsToAverageOver_ [private]

Definition at line 84 of file SiPixelGainCalibrationForHLT.h.

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

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

Definition at line 80 of file SiPixelGainCalibrationForHLT.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