CMS 3D CMS Logo

List of all members | Classes | Public Types | Public Member Functions | Private Member Functions | Private Attributes | Friends
SiPixelGainCalibrationForHLT Class Reference

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

Classes

struct  DecodingStructure
 
struct  DetRegistry
 
class  StrictWeakOrdering
 

Public Types

typedef std::vector< char >::const_iterator ContainerIterator
 
typedef std::pair< ContainerIterator, ContainerIteratorRange
 
typedef std::vector< DetRegistryRegistry
 
typedef Registry::const_iterator RegistryIterator
 

Public Member Functions

std::vector< char > const & data () const
 
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
 
float getGainHigh () const
 
float getGainLow () const
 
std::vector< DetRegistry > const & getIndexes () 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
 
std::pair< float, float > getPedAndGain (const int &col, const int &row, const Range &range, const int &nCols, bool &isDeadColumn, bool &isNoisyColumn) const
 
float getPedHigh () const
 
float getPedLow () const
 
const Range getRange (const uint32_t &detID) const
 
const std::pair< const Range, const int > getRangeAndNCols (const uint32_t &detID) const
 
void initialize ()
 
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 ()
 
 SiPixelGainCalibrationForHLT (float minPed, float maxPed, float minGain, float maxGain)
 
 ~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)
 
template<class Archive >
void serialize (Archive &ar, const unsigned int version)
 

Private Attributes

unsigned int deadFlag_
 
float gainPrecision
 
std::vector< DetRegistryindexes
 
float maxGain_
 
float maxPed_
 
float minGain_
 
float minPed_
 
unsigned int nBinsToUseForEncoding_
 
unsigned int noisyFlag_
 
unsigned int numberOfRowsToAverageOver_
 
float pedPrecision
 
std::vector< char > v_pedestals
 

Friends

class boost::serialization::access
 
template<typename CondSerializationT , typename Enabled >
struct cond::serialization::access
 

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 29 of file SiPixelGainCalibrationForHLT.h.

Member Typedef Documentation

◆ ContainerIterator

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

Definition at line 50 of file SiPixelGainCalibrationForHLT.h.

◆ Range

Definition at line 51 of file SiPixelGainCalibrationForHLT.h.

◆ Registry

Definition at line 52 of file SiPixelGainCalibrationForHLT.h.

◆ RegistryIterator

typedef Registry::const_iterator SiPixelGainCalibrationForHLT::RegistryIterator

Definition at line 53 of file SiPixelGainCalibrationForHLT.h.

Constructor & Destructor Documentation

◆ SiPixelGainCalibrationForHLT() [1/2]

SiPixelGainCalibrationForHLT::SiPixelGainCalibrationForHLT ( )

Definition at line 9 of file SiPixelGainCalibrationForHLT.cc.

References deadFlag_, Exception, and initialize().

10  : minPed_(0.),
11  maxPed_(255.),
12  minGain_(0.),
13  maxGain_(255.),
16  deadFlag_(255),
17  noisyFlag_(254) {
18  initialize();
19  if (deadFlag_ > 0xFF)
20  throw cms::Exception("GainCalibration Payload configuration error")
21  << "[SiPixelGainCalibrationHLT::SiPixelGainCalibrationHLT] Dead flag was set to " << deadFlag_
22  << ", and it must be set less than or equal to 255";
23 }

◆ SiPixelGainCalibrationForHLT() [2/2]

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

Definition at line 25 of file SiPixelGainCalibrationForHLT.cc.

References deadFlag_, Exception, and initialize().

26  : minPed_(minPed),
27  maxPed_(maxPed),
28  minGain_(minGain),
29  maxGain_(maxGain),
32  deadFlag_(255),
33  noisyFlag_(254) {
34  initialize();
35  if (deadFlag_ > 0xFF)
36  throw cms::Exception("GainCalibration Payload configuration error")
37  << "[SiPixelGainCalibrationHLT::SiPixelGainCalibrationHLT] Dead flag was set to " << deadFlag_
38  << ", and it must be set less than or equal to 255";
39 }

◆ ~SiPixelGainCalibrationForHLT()

SiPixelGainCalibrationForHLT::~SiPixelGainCalibrationForHLT ( )
inline

Definition at line 58 of file SiPixelGainCalibrationForHLT.h.

58 {}

Member Function Documentation

◆ data()

std::vector<char> const& SiPixelGainCalibrationForHLT::data ( ) const
inline

◆ decodeGain()

float SiPixelGainCalibrationForHLT::decodeGain ( unsigned int  gain) const
inlineprivate

◆ decodePed()

float SiPixelGainCalibrationForHLT::decodePed ( unsigned int  ped) const
inlineprivate

◆ encodeGain()

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

Definition at line 217 of file SiPixelGainCalibrationForHLT.cc.

References Exception, nano_mu_digi_cff::float, PedestalClient_cfi::gain, maxGain_, minGain_, nBinsToUseForEncoding_, and hcalRecHitTable_cff::precision.

Referenced by setData().

217  {
218  if (gain < minGain_ || gain > maxGain_) {
219  throw cms::Exception("InsertFailure") << "[SiPixelGainCalibrationForHLT::encodeGain] Trying to encode gain ("
220  << gain << ") out of range [" << minGain_ << "," << maxGain_ << "]\n";
221  } else {
222  float precision = (maxGain_ - minGain_) / static_cast<float>(nBinsToUseForEncoding_);
223  float encodedGain = (float)((gain - minGain_) / precision);
224  return encodedGain;
225  }
226 }

◆ encodePed()

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

Definition at line 228 of file SiPixelGainCalibrationForHLT.cc.

References Exception, nano_mu_digi_cff::float, maxPed_, minPed_, nBinsToUseForEncoding_, and hcalRecHitTable_cff::precision.

Referenced by setData().

228  {
229  if (ped < minPed_ || ped > maxPed_) {
230  throw cms::Exception("InsertFailure") << "[SiPixelGainCalibrationForHLT::encodePed] Trying to encode pedestal ("
231  << ped << ") out of range [" << minPed_ << "," << maxPed_ << "]\n";
232  } else {
233  float precision = (maxPed_ - minPed_) / static_cast<float>(nBinsToUseForEncoding_);
234  float encodedPed = (float)((ped - minPed_) / precision);
235  return encodedPed;
236  }
237 }

◆ getDetIds()

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

Definition at line 99 of file SiPixelGainCalibrationForHLT.cc.

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

99  {
100  // returns vector of DetIds in map
104  DetIds_.push_back(p->detid);
105  }
106 }
Registry::const_iterator RegistryIterator

◆ getGain()

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

Definition at line 191 of file SiPixelGainCalibrationForHLT.cc.

References cuy::col, deadFlag_, decodeGain(), Exception, PedestalClient_cfi::gain, noisyFlag_, numberOfRowsToAverageOver_, and FastTimerService_cff::range.

196  {
197  // 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
198  unsigned int lengthOfColumnData = (range.second - range.first) / nCols;
199  unsigned int lengthOfAveragedDataInEachColumn = 2; // we always only have two values per column averaged block
200  unsigned int numberOfDataBlocksToSkip = row / numberOfRowsToAverageOver_;
201  const unsigned int gain =
202  *(range.first + col * lengthOfColumnData + lengthOfAveragedDataInEachColumn * numberOfDataBlocksToSkip) & 0xFF;
203 
204  if (gain == deadFlag_)
205  isDeadColumn = true;
206  else if (gain == noisyFlag_)
207  isNoisyColumn = true;
208 
209  int maxRow = (lengthOfColumnData / lengthOfAveragedDataInEachColumn) * numberOfRowsToAverageOver_ - 1;
210  if (col >= nCols || row > maxRow) {
211  throw cms::Exception("CorruptedData")
212  << "[SiPixelGainCalibrationForHLT::getGain] Pixel out of range: col " << col << " row: " << row;
213  }
214  return decodeGain(gain);
215 }
float decodeGain(unsigned int gain) const
col
Definition: cuy.py:1009

◆ getGainHigh()

float SiPixelGainCalibrationForHLT::getGainHigh ( ) const
inline

Definition at line 70 of file SiPixelGainCalibrationForHLT.h.

References maxGain_.

◆ getGainLow()

float SiPixelGainCalibrationForHLT::getGainLow ( ) const
inline

Definition at line 69 of file SiPixelGainCalibrationForHLT.h.

References minGain_.

◆ getIndexes()

std::vector<DetRegistry> const& SiPixelGainCalibrationForHLT::getIndexes ( ) const
inline

Definition at line 75 of file SiPixelGainCalibrationForHLT.h.

References indexes.

75 { return indexes; }

◆ getNCols()

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

◆ getNumberOfRowsToAverageOver()

unsigned int SiPixelGainCalibrationForHLT::getNumberOfRowsToAverageOver ( ) const
inline

◆ getPed()

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

Definition at line 162 of file SiPixelGainCalibrationForHLT.cc.

References cuy::col, deadFlag_, decodePed(), Exception, noisyFlag_, numberOfRowsToAverageOver_, and FastTimerService_cff::range.

167  {
168  // TODO MERGE THIS FUNCTION WITH GET GAIN, then provide wrappers ( VI done, see above)
169 
170  // 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
171  unsigned int lengthOfColumnData = (range.second - range.first) / nCols;
172  unsigned int lengthOfAveragedDataInEachColumn = 2; // we always only have two values per column averaged block
173  unsigned int numberOfDataBlocksToSkip = row / numberOfRowsToAverageOver_;
174  const unsigned int ped =
175  *(range.first + 1 + col * lengthOfColumnData + lengthOfAveragedDataInEachColumn * numberOfDataBlocksToSkip) &
176  0xFF;
177 
178  if (ped == deadFlag_)
179  isDeadColumn = true;
180  else if (ped == noisyFlag_)
181  isNoisyColumn = true;
182 
183  int maxRow = (lengthOfColumnData / lengthOfAveragedDataInEachColumn) * numberOfRowsToAverageOver_ - 1;
184  if (col >= nCols || row > maxRow) {
185  throw cms::Exception("CorruptedData")
186  << "[SiPixelGainCalibrationForHLT::getPed] Pixel out of range: col " << col << " row: " << row;
187  }
188  return decodePed(ped);
189 }
float decodePed(unsigned int ped) const
col
Definition: cuy.py:1009

◆ getPedAndGain()

std::pair< float, float > SiPixelGainCalibrationForHLT::getPedAndGain ( const int &  col,
const int &  row,
const Range range,
const int &  nCols,
bool &  isDeadColumn,
bool &  isNoisyColumn 
) const

Definition at line 134 of file SiPixelGainCalibrationForHLT.cc.

References cuy::col, deadFlag_, decodeGain(), decodePed(), PedestalClient_cfi::gain, noisyFlag_, numberOfRowsToAverageOver_, and FastTimerService_cff::range.

Referenced by SiPixelGainCalibrationForHLTService::calibrate().

139  {
140  // 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
141  unsigned int lengthOfColumnData = (range.second - range.first) / nCols;
142  unsigned int lengthOfAveragedDataInEachColumn = 2; // we always only have two values per column averaged block
143  unsigned int numberOfDataBlocksToSkip = row / numberOfRowsToAverageOver_;
144  const unsigned int pos = col * lengthOfColumnData + lengthOfAveragedDataInEachColumn * numberOfDataBlocksToSkip;
145  const unsigned int gain = *(range.first + pos) & 0xFF;
146  const unsigned int ped = *(range.first + pos + 1) & 0xFF;
147 
148  isDeadColumn = ped == deadFlag_;
149  isNoisyColumn = ped == noisyFlag_;
150 
151  /*
152  int maxRow = (lengthOfColumnData/lengthOfAveragedDataInEachColumn)*numberOfRowsToAverageOver_ - 1;
153  if (col >= nCols || row > maxRow){
154  throw cms::Exception("CorruptedData")
155  << "[SiPixelGainCalibrationForHLT::getPed] Pixel out of range: col " << col << " row: " << row;
156  }
157  */
158 
159  return std::make_pair(decodePed(ped), decodeGain(gain));
160 }
float decodeGain(unsigned int gain) const
float decodePed(unsigned int ped) const
col
Definition: cuy.py:1009

◆ getPedHigh()

float SiPixelGainCalibrationForHLT::getPedHigh ( ) const
inline

Definition at line 72 of file SiPixelGainCalibrationForHLT.h.

References maxPed_.

◆ getPedLow()

float SiPixelGainCalibrationForHLT::getPedLow ( ) const
inline

Definition at line 71 of file SiPixelGainCalibrationForHLT.h.

References minPed_.

◆ getRange()

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

◆ getRangeAndNCols()

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

Definition at line 88 of file SiPixelGainCalibrationForHLT.cc.

References indexes, pfDeepBoostedJetPreprocessParams_cfi::lower_bound, AlCaHLTBitMon_ParallelJobs::p, and v_pedestals.

Referenced by SiPixelGainCalibrationForHLTService::calibrate().

89  {
92  if (p == indexes.end() || p->detid != DetId)
93  return std::make_pair(SiPixelGainCalibrationForHLT::Range(v_pedestals.end(), v_pedestals.end()), 0);
94  else
95  return std::make_pair(
96  SiPixelGainCalibrationForHLT::Range(v_pedestals.begin() + p->ibegin, v_pedestals.begin() + p->iend), p->ncols);
97 }
std::pair< ContainerIterator, ContainerIterator > Range
Definition: DetId.h:17
Registry::const_iterator RegistryIterator

◆ initialize()

void SiPixelGainCalibrationForHLT::initialize ( )

◆ put()

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

Definition at line 46 of file SiPixelGainCalibrationForHLT.cc.

References SiPixelGainCalibrationForHLT::DetRegistry::detid, SiPixelGainCalibrationForHLT::DetRegistry::ibegin, SiPixelGainCalibrationForHLT::DetRegistry::iend, indexes, input, pfDeepBoostedJetPreprocessParams_cfi::lower_bound, SiPixelGainCalibrationForHLT::DetRegistry::ncols, AlCaHLTBitMon_ParallelJobs::p, and v_pedestals.

Referenced by SiPixelGainCalibrationReadDQMFile::fillDatabase().

46  {
47  // put in SiPixelGainCalibrationForHLT of DetId
48 
49  Registry::iterator p =
51  if (p != indexes.end() && p->detid == DetId)
52  return false;
53 
54  size_t sd = input.second - input.first;
55  DetRegistry detregistry;
56  detregistry.detid = DetId;
57  detregistry.ibegin = v_pedestals.size();
58  detregistry.iend = v_pedestals.size() + sd;
59  detregistry.ncols = nCols;
60  indexes.insert(p, detregistry);
61 
62  v_pedestals.insert(v_pedestals.end(), input.first, input.second);
63  return true;
64 }
static std::string const input
Definition: EdmProvDump.cc:50
Definition: DetId.h:17

◆ serialize()

template<class Archive >
void SiPixelGainCalibrationForHLT::serialize ( Archive &  ar,
const unsigned int  version 
)
private

◆ setData()

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

Definition at line 108 of file SiPixelGainCalibrationForHLT.cc.

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

Referenced by SiPixelGainCalibrationReadDQMFile::fillDatabase(), setDeadColumn(), and setNoisyColumn().

109  {
110  float theEncodedGain = 0;
111  float theEncodedPed = 0;
112  if (!thisColumnIsDead && !thisColumnIsNoisy) {
113  theEncodedGain = encodeGain(gain);
114  theEncodedPed = encodePed(ped);
115  }
116 
117  unsigned int ped_ = (static_cast<unsigned int>(theEncodedPed)) & 0xFF;
118  unsigned int gain_ = (static_cast<unsigned int>(theEncodedGain)) & 0xFF;
119 
120  if (thisColumnIsDead) {
121  ped_ = deadFlag_ & 0xFF;
122  gain_ = deadFlag_ & 0xFF;
123  } else if (thisColumnIsNoisy) {
124  ped_ = noisyFlag_ & 0xFF;
125  gain_ = noisyFlag_ & 0xFF;
126  }
127 
128  unsigned int data = (ped_ << 8) | gain_;
129  vped.resize(vped.size() + 2);
130  // insert in vector of char
131  ::memcpy((void*)(&vped[vped.size() - 2]), (void*)(&data), 2);
132 }
std::vector< char > const & data() const
static const char gain_[]

◆ setDeadColumn()

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

Definition at line 80 of file SiPixelGainCalibrationForHLT.h.

References setData().

Referenced by SiPixelGainCalibrationReadDQMFile::fillDatabase().

80  {
81  setData(0, 0 /*dummy values, not used*/, vped, true, false);
82  }
void setData(float ped, float gain, std::vector< char > &vped, bool thisColumnIsDead=false, bool thisColumnIsNoisy=false)

◆ setNoisyColumn()

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

Definition at line 83 of file SiPixelGainCalibrationForHLT.h.

References setData().

83  {
84  setData(0, 0 /*dummy values, not used*/, vped, false, true);
85  }
void setData(float ped, float gain, std::vector< char > &vped, bool thisColumnIsDead=false, bool thisColumnIsNoisy=false)

Friends And Related Function Documentation

◆ boost::serialization::access

friend class boost::serialization::access
friend

Definition at line 126 of file SiPixelGainCalibrationForHLT.h.

◆ cond::serialization::access

template<typename CondSerializationT , typename Enabled >
friend struct cond::serialization::access
friend

Definition at line 126 of file SiPixelGainCalibrationForHLT.h.

Member Data Documentation

◆ deadFlag_

unsigned int SiPixelGainCalibrationForHLT::deadFlag_
private

◆ gainPrecision

float SiPixelGainCalibrationForHLT::gainPrecision
private

Definition at line 117 of file SiPixelGainCalibrationForHLT.h.

Referenced by decodeGain(), and initialize().

◆ indexes

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

◆ maxGain_

float SiPixelGainCalibrationForHLT::maxGain_
private

Definition at line 115 of file SiPixelGainCalibrationForHLT.h.

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

◆ maxPed_

float SiPixelGainCalibrationForHLT::maxPed_
private

Definition at line 115 of file SiPixelGainCalibrationForHLT.h.

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

◆ minGain_

float SiPixelGainCalibrationForHLT::minGain_
private

Definition at line 115 of file SiPixelGainCalibrationForHLT.h.

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

◆ minPed_

float SiPixelGainCalibrationForHLT::minPed_
private

Definition at line 115 of file SiPixelGainCalibrationForHLT.h.

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

◆ nBinsToUseForEncoding_

unsigned int SiPixelGainCalibrationForHLT::nBinsToUseForEncoding_
private

Definition at line 122 of file SiPixelGainCalibrationForHLT.h.

Referenced by encodeGain(), encodePed(), and initialize().

◆ noisyFlag_

unsigned int SiPixelGainCalibrationForHLT::noisyFlag_
private

Definition at line 124 of file SiPixelGainCalibrationForHLT.h.

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

◆ numberOfRowsToAverageOver_

unsigned int SiPixelGainCalibrationForHLT::numberOfRowsToAverageOver_
private

◆ pedPrecision

float SiPixelGainCalibrationForHLT::pedPrecision
private

Definition at line 117 of file SiPixelGainCalibrationForHLT.h.

Referenced by decodePed(), and initialize().

◆ v_pedestals

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

Definition at line 113 of file SiPixelGainCalibrationForHLT.h.

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