CMS 3D CMS Logo

Classes | Public Types | Public Member Functions | Private Member Functions | Private Attributes

SiPixelGainCalibrationForHLT Class Reference

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

List of all members.

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< 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, 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 &isDeadColumn, bool &isNoisyColumn) 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 thisColumnIsDead=false, bool thisColumnIsNoisy=false)
void setDeadColumn (const int &nRows, std::vector< char > &vped)
void setNoisyColumn (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 noisyFlag_
unsigned int numberOfRowsToAverageOver_
std::vector< char > v_pedestals

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.

Definition at line 49 of file SiPixelGainCalibrationForHLT.h.

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 9 of file SiPixelGainCalibrationForHLT.cc.

References deadFlag_, and Exception.

                                                           :
  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")
         << "[SiPixelGainCalibrationHLT::SiPixelGainCalibrationHLT] Dead flag was set to " << deadFlag_ << ", and it must be set less than or equal to 255";
}
SiPixelGainCalibrationForHLT::SiPixelGainCalibrationForHLT ( float  minPed,
float  maxPed,
float  minGain,
float  maxGain 
)

Definition at line 24 of file SiPixelGainCalibrationForHLT.cc.

References deadFlag_, and Exception.

                                                                                                                   :
  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")
         << "[SiPixelGainCalibrationHLT::SiPixelGainCalibrationHLT] Dead flag was set to " << deadFlag_ << ", and it must be set less than or equal to 255";
}
virtual SiPixelGainCalibrationForHLT::~SiPixelGainCalibrationForHLT ( ) [inline, virtual]

Definition at line 56 of file SiPixelGainCalibrationForHLT.h.

{};

Member Function Documentation

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

Definition at line 206 of file SiPixelGainCalibrationForHLT.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 SiPixelGainCalibrationForHLT::decodePed ( unsigned int  ped) const [private]

Definition at line 198 of file SiPixelGainCalibrationForHLT.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 SiPixelGainCalibrationForHLT::encodeGain ( const float &  gain) [private]

Definition at line 172 of file SiPixelGainCalibrationForHLT.cc.

References Exception, maxGain_, minGain_, and nBinsToUseForEncoding_.

Referenced by setData().

                                                                  {
  
  if(gain < minGain_ || gain > maxGain_ ) {
    throw cms::Exception("InsertFailure")
      << "[SiPixelGainCalibrationForHLT::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 SiPixelGainCalibrationForHLT::encodePed ( const float &  ped) [private]

Definition at line 185 of file SiPixelGainCalibrationForHLT.cc.

References Exception, maxPed_, minPed_, and nBinsToUseForEncoding_.

Referenced by setData().

                                                                {

  if(ped < minPed_ || ped > maxPed_ ) {
    throw cms::Exception("InsertFailure")
      << "[SiPixelGainCalibrationForHLT::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 SiPixelGainCalibrationForHLT::getDetIds ( std::vector< uint32_t > &  DetIds_) const

Definition at line 88 of file SiPixelGainCalibrationForHLT.cc.

References begin, end, indexes, and AlCaHLTBitMon_ParallelJobs::p.

                                                                               {
  // returns vector of DetIds in map
  SiPixelGainCalibrationForHLT::RegistryIterator begin = indexes.begin();
  SiPixelGainCalibrationForHLT::RegistryIterator end   = indexes.end();
  for (SiPixelGainCalibrationForHLT::RegistryIterator p=begin; p != end; ++p) {
    DetIds_.push_back(p->detid);
  }
}
float SiPixelGainCalibrationForHLT::getGain ( const int &  col,
const int &  row,
const Range range,
const int &  nCols,
bool &  isDeadColumn,
bool &  isNoisyColumn 
) const

Definition at line 149 of file SiPixelGainCalibrationForHLT.cc.

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

                                                                                                                                                               {

  // 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
  unsigned int lengthOfColumnData  = (range.second-range.first)/nCols;
  unsigned int lengthOfAveragedDataInEachColumn = 2;  // we always only have two values per column averaged block 
  unsigned int numberOfDataBlocksToSkip = row / numberOfRowsToAverageOver_;

  const DecodingStructure & s = (const DecodingStructure & ) *(range.first+col*lengthOfColumnData + lengthOfAveragedDataInEachColumn*numberOfDataBlocksToSkip);

  if ((s.gain & 0xFF) == deadFlag_)
     isDeadColumn = true;
  else if ((s.gain & 0xFF) == noisyFlag_)
     isNoisyColumn = true;
     
  int maxRow = (lengthOfColumnData/lengthOfAveragedDataInEachColumn)*numberOfRowsToAverageOver_ - 1;
  if (col >= nCols || row > maxRow){
    throw cms::Exception("CorruptedData")
      << "[SiPixelGainCalibrationForHLT::getGain] Pixel out of range: col " << col << " row: " << row;
  }  
  return decodeGain(s.gain & 0xFF);  

}
double SiPixelGainCalibrationForHLT::getGainHigh ( ) const [inline]

Definition at line 66 of file SiPixelGainCalibrationForHLT.h.

References maxGain_.

{ return maxGain_; }
double SiPixelGainCalibrationForHLT::getGainLow ( ) const [inline]

Definition at line 65 of file SiPixelGainCalibrationForHLT.h.

References minGain_.

{ return minGain_; }
const int SiPixelGainCalibrationForHLT::getNCols ( const uint32_t &  detID) const

Definition at line 58 of file SiPixelGainCalibrationForHLT.cc.

References indexes, and AlCaHLTBitMon_ParallelJobs::p.

                                                                            {
  // get number of columns of DetId
  RegistryIterator p = std::lower_bound(indexes.begin(),indexes.end(),DetId,SiPixelGainCalibrationForHLT::StrictWeakOrdering());
  if (p==indexes.end()|| p->detid!=DetId) 
    return 0;
  else
  {
    return p->ncols;
  }
}
unsigned int SiPixelGainCalibrationForHLT::getNumberOfRowsToAverageOver ( ) const [inline]

Definition at line 64 of file SiPixelGainCalibrationForHLT.h.

References numberOfRowsToAverageOver_.

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

Definition at line 126 of file SiPixelGainCalibrationForHLT.cc.

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

                                                                                                                                                              {
   // TODO MERGE THIS FUNCTION WITH GET GAIN, then provide wrappers

  // 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
  unsigned int lengthOfColumnData  = (range.second-range.first)/nCols;
  unsigned int lengthOfAveragedDataInEachColumn = 2;  // we always only have two values per column averaged block 
  unsigned int numberOfDataBlocksToSkip = row / numberOfRowsToAverageOver_;

  const DecodingStructure & s = (const DecodingStructure & ) *(range.first+col*lengthOfColumnData + lengthOfAveragedDataInEachColumn*numberOfDataBlocksToSkip);

  if ((s.ped & 0xFF) == deadFlag_)
     isDeadColumn = true;
  else if ((s.ped & 0xFF) == noisyFlag_)
     isNoisyColumn = true;

  int maxRow = (lengthOfColumnData/lengthOfAveragedDataInEachColumn)*numberOfRowsToAverageOver_ - 1;
  if (col >= nCols || row > maxRow){
    throw cms::Exception("CorruptedData")
      << "[SiPixelGainCalibrationForHLT::getPed] Pixel out of range: col " << col << " row: " << row;
  }  
  return decodePed(s.ped & 0xFF);  
}
double SiPixelGainCalibrationForHLT::getPedHigh ( ) const [inline]

Definition at line 68 of file SiPixelGainCalibrationForHLT.h.

References maxPed_.

{ return maxPed_; }
double SiPixelGainCalibrationForHLT::getPedLow ( ) const [inline]

Definition at line 67 of file SiPixelGainCalibrationForHLT.h.

References minPed_.

{ return minPed_; }
const SiPixelGainCalibrationForHLT::Range SiPixelGainCalibrationForHLT::getRange ( const uint32_t &  detID) const

Definition at line 69 of file SiPixelGainCalibrationForHLT.cc.

References indexes, AlCaHLTBitMon_ParallelJobs::p, and v_pedestals.

                                                                                                          {
  // get SiPixelGainCalibrationForHLT Range of DetId
  
  RegistryIterator p = std::lower_bound(indexes.begin(),indexes.end(),DetId,SiPixelGainCalibrationForHLT::StrictWeakOrdering());
  if (p==indexes.end()|| p->detid!=DetId) 
    return SiPixelGainCalibrationForHLT::Range(v_pedestals.end(),v_pedestals.end()); 
  else 
    return SiPixelGainCalibrationForHLT::Range(v_pedestals.begin()+p->ibegin,v_pedestals.begin()+p->iend);
}
const std::pair< const SiPixelGainCalibrationForHLT::Range, const int > SiPixelGainCalibrationForHLT::getRangeAndNCols ( const uint32_t &  detID) const

Definition at line 80 of file SiPixelGainCalibrationForHLT.cc.

References indexes, AlCaHLTBitMon_ParallelJobs::p, and v_pedestals.

                                                                          {
  RegistryIterator p = std::lower_bound(indexes.begin(),indexes.end(),DetId,SiPixelGainCalibrationForHLT::StrictWeakOrdering());
  if (p==indexes.end()|| p->detid!=DetId) 
    return std::make_pair(SiPixelGainCalibrationForHLT::Range(v_pedestals.end(),v_pedestals.end()), 0); 
  else 
    return std::make_pair(SiPixelGainCalibrationForHLT::Range(v_pedestals.begin()+p->ibegin,v_pedestals.begin()+p->iend), p->ncols);
}
bool SiPixelGainCalibrationForHLT::put ( const uint32_t &  detID,
Range  input,
const int &  nCols 
)

Definition at line 39 of file SiPixelGainCalibrationForHLT.cc.

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

                                                                                           {
  // put in SiPixelGainCalibrationForHLT of DetId

  Registry::iterator p = std::lower_bound(indexes.begin(),indexes.end(),DetId,SiPixelGainCalibrationForHLT::StrictWeakOrdering());
  if (p!=indexes.end() && p->detid==DetId)
    return false;
  
  size_t sd= input.second-input.first;
  DetRegistry detregistry;
  detregistry.detid=DetId;
  detregistry.ibegin=v_pedestals.size();
  detregistry.iend=v_pedestals.size()+sd;
  detregistry.ncols=nCols;
  indexes.insert(p,detregistry);

  v_pedestals.insert(v_pedestals.end(),input.first,input.second);
  return true;
}
void SiPixelGainCalibrationForHLT::setData ( float  ped,
float  gain,
std::vector< char > &  vped,
bool  thisColumnIsDead = false,
bool  thisColumnIsNoisy = false 
)

Definition at line 97 of file SiPixelGainCalibrationForHLT.cc.

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

Referenced by setDeadColumn(), and setNoisyColumn().

                                                                                                                                     {
  
  float theEncodedGain=0;
  float theEncodedPed=0;
  if(!thisColumnIsDead && !thisColumnIsNoisy){
    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 (thisColumnIsDead)
  {
     ped_  = deadFlag_ & 0xFF;
     gain_ = deadFlag_ & 0xFF;
  }
  else if (thisColumnIsNoisy)
  {
     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 SiPixelGainCalibrationForHLT::setDeadColumn ( const int &  nRows,
std::vector< char > &  vped 
) [inline]

Definition at line 72 of file SiPixelGainCalibrationForHLT.h.

References setData().

{ setData(0, 0 /*dummy values, not used*/, vped, true, false); }
void SiPixelGainCalibrationForHLT::setNoisyColumn ( const int &  nRows,
std::vector< char > &  vped 
) [inline]

Definition at line 73 of file SiPixelGainCalibrationForHLT.h.

References setData().

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

Member Data Documentation

Definition at line 86 of file SiPixelGainCalibrationForHLT.h.

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

Definition at line 87 of file SiPixelGainCalibrationForHLT.h.

Referenced by decodeGain(), encodeGain(), and getGainHigh().

Definition at line 87 of file SiPixelGainCalibrationForHLT.h.

Referenced by decodePed(), encodePed(), and getPedHigh().

Definition at line 87 of file SiPixelGainCalibrationForHLT.h.

Referenced by decodeGain(), encodeGain(), and getGainLow().

Definition at line 87 of file SiPixelGainCalibrationForHLT.h.

Referenced by decodePed(), encodePed(), and getPedLow().

Definition at line 90 of file SiPixelGainCalibrationForHLT.h.

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

Definition at line 92 of file SiPixelGainCalibrationForHLT.h.

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

Definition at line 89 of file SiPixelGainCalibrationForHLT.h.

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

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

Definition at line 85 of file SiPixelGainCalibrationForHLT.h.

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