CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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,
ContainerIterator
Range
 
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

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

Definition at line 50 of file SiPixelGainCalibrationForHLT.h.

Definition at line 51 of file SiPixelGainCalibrationForHLT.h.

Definition at line 52 of file SiPixelGainCalibrationForHLT.h.

typedef Registry::const_iterator SiPixelGainCalibrationForHLT::RegistryIterator

Definition at line 53 of file SiPixelGainCalibrationForHLT.h.

Constructor & Destructor Documentation

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::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 ( )
inline

Definition at line 58 of file SiPixelGainCalibrationForHLT.h.

58 {}

Member Function Documentation

std::vector<char> const& SiPixelGainCalibrationForHLT::data ( ) const
inline
float SiPixelGainCalibrationForHLT::decodeGain ( unsigned int  gain) const
inlineprivate

Definition at line 110 of file SiPixelGainCalibrationForHLT.h.

References gainPrecision, and minGain_.

Referenced by getGain(), and getPedAndGain().

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

Definition at line 111 of file SiPixelGainCalibrationForHLT.h.

References minPed_, and pedPrecision.

Referenced by getPed(), and getPedAndGain().

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

Definition at line 217 of file SiPixelGainCalibrationForHLT.cc.

References Exception, maxGain_, minGain_, and nBinsToUseForEncoding_.

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 }
float SiPixelGainCalibrationForHLT::encodePed ( const float &  ped)
private

Definition at line 228 of file SiPixelGainCalibrationForHLT.cc.

References Exception, maxPed_, minPed_, and nBinsToUseForEncoding_.

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 }
void SiPixelGainCalibrationForHLT::getDetIds ( std::vector< uint32_t > &  DetIds_) const

Definition at line 99 of file SiPixelGainCalibrationForHLT.cc.

References SplitLinear::begin, dataset::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
string end
Definition: dataset.py:937
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 deadFlag_, decodeGain(), Exception, noisyFlag_, and numberOfRowsToAverageOver_.

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 }
const uint16_t range(const Frame &aFrame)
float decodeGain(unsigned int gain) const
int col
Definition: cuy.py:1009
float SiPixelGainCalibrationForHLT::getGainHigh ( ) const
inline
float SiPixelGainCalibrationForHLT::getGainLow ( ) const
inline
std::vector<DetRegistry> const& SiPixelGainCalibrationForHLT::getIndexes ( ) const
inline

Definition at line 75 of file SiPixelGainCalibrationForHLT.h.

References indexes.

Referenced by SiPixelGainCalibrationForHLTGPU::SiPixelGainCalibrationForHLTGPU().

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

Definition at line 66 of file SiPixelGainCalibrationForHLT.cc.

References indexes, cuda_std::lower_bound(), and AlCaHLTBitMon_ParallelJobs::p.

66  {
67  // get number of columns of DetId
70  if (p == indexes.end() || p->detid != DetId)
71  return 0;
72  else {
73  return p->ncols;
74  }
75 }
Definition: DetId.h:17
Registry::const_iterator RegistryIterator
__host__ __device__ constexpr RandomIt lower_bound(RandomIt first, RandomIt last, const T &value, Compare comp={})
unsigned int SiPixelGainCalibrationForHLT::getNumberOfRowsToAverageOver ( ) const
inline
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 deadFlag_, decodePed(), Exception, noisyFlag_, and numberOfRowsToAverageOver_.

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 }
const uint16_t range(const Frame &aFrame)
float decodePed(unsigned int ped) const
int col
Definition: cuy.py:1009
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 deadFlag_, decodeGain(), decodePed(), noisyFlag_, and numberOfRowsToAverageOver_.

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 }
const uint16_t range(const Frame &aFrame)
float decodePed(unsigned int ped) const
float decodeGain(unsigned int gain) const
int col
Definition: cuy.py:1009
float SiPixelGainCalibrationForHLT::getPedHigh ( ) const
inline
float SiPixelGainCalibrationForHLT::getPedLow ( ) const
inline
const SiPixelGainCalibrationForHLT::Range SiPixelGainCalibrationForHLT::getRange ( const uint32_t &  detID) const

Definition at line 77 of file SiPixelGainCalibrationForHLT.cc.

References indexes, cuda_std::lower_bound(), AlCaHLTBitMon_ParallelJobs::p, and v_pedestals.

77  {
78  // get SiPixelGainCalibrationForHLT Range of DetId
79 
82  if (p == indexes.end() || p->detid != DetId)
84  else
85  return SiPixelGainCalibrationForHLT::Range(v_pedestals.begin() + p->ibegin, v_pedestals.begin() + p->iend);
86 }
std::pair< ContainerIterator, ContainerIterator > Range
Definition: DetId.h:17
Registry::const_iterator RegistryIterator
__host__ __device__ constexpr RandomIt lower_bound(RandomIt first, RandomIt last, const T &value, Compare comp={})
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, cuda_std::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
__host__ __device__ constexpr RandomIt lower_bound(RandomIt first, RandomIt last, const T &value, Compare comp={})
void SiPixelGainCalibrationForHLT::initialize ( )
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, cuda_std::lower_bound(), SiPixelGainCalibrationForHLT::DetRegistry::ncols, AlCaHLTBitMon_ParallelJobs::p, sd, 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:47
Definition: DetId.h:17
double sd
__host__ __device__ constexpr RandomIt lower_bound(RandomIt first, RandomIt last, const T &value, Compare comp={})
template<class Archive >
void SiPixelGainCalibrationForHLT::serialize ( Archive &  ar,
const unsigned int  version 
)
private
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(), 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_[]
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)
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

friend class boost::serialization::access
friend

Definition at line 126 of file SiPixelGainCalibrationForHLT.h.

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

Definition at line 126 of file SiPixelGainCalibrationForHLT.h.

Member Data Documentation

unsigned int SiPixelGainCalibrationForHLT::deadFlag_
private
float SiPixelGainCalibrationForHLT::gainPrecision
private

Definition at line 117 of file SiPixelGainCalibrationForHLT.h.

Referenced by decodeGain(), and initialize().

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

Definition at line 115 of file SiPixelGainCalibrationForHLT.h.

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

float SiPixelGainCalibrationForHLT::maxPed_
private

Definition at line 115 of file SiPixelGainCalibrationForHLT.h.

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

float SiPixelGainCalibrationForHLT::minGain_
private

Definition at line 115 of file SiPixelGainCalibrationForHLT.h.

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

float SiPixelGainCalibrationForHLT::minPed_
private

Definition at line 115 of file SiPixelGainCalibrationForHLT.h.

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

unsigned int SiPixelGainCalibrationForHLT::nBinsToUseForEncoding_
private

Definition at line 122 of file SiPixelGainCalibrationForHLT.h.

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

unsigned int SiPixelGainCalibrationForHLT::noisyFlag_
private

Definition at line 124 of file SiPixelGainCalibrationForHLT.h.

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

unsigned int SiPixelGainCalibrationForHLT::numberOfRowsToAverageOver_
private
float SiPixelGainCalibrationForHLT::pedPrecision
private

Definition at line 117 of file SiPixelGainCalibrationForHLT.h.

Referenced by decodePed(), and initialize().

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

Definition at line 113 of file SiPixelGainCalibrationForHLT.h.

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