CMS 3D CMS Logo

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

#include <CondFormats/SiPixelObjects/src/SiPixelGainCalibrationOffline.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

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 &isDead, bool &isNoisy) 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
 
void initialize ()
 
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, bool thisColumnIsNoisy=false)
 
void setDataPedestal (float pedestal, std::vector< char > &vped, bool thisPixelIsDead=false, bool thisPixelIsNoisy=false)
 
void setDeadColumn (const int &nRows, std::vector< char > &vped)
 
void setDeadPixel (std::vector< char > &vped)
 
void setNoisyColumn (const int &nRows, std::vector< char > &vped)
 
void setNoisyPixel (std::vector< char > &vped)
 
 SiPixelGainCalibrationOffline ()
 
 SiPixelGainCalibrationOffline (float minPed, float maxPed, float minGain, float maxGain)
 
 ~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)
 
template<class Archive >
void serialize (Archive &ar, const unsigned int version)
 

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
 

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. Stores pedestal at pixel granularity, gain at column granularity.

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

Definition at line 29 of file SiPixelGainCalibrationOffline.h.

Member Typedef Documentation

◆ ContainerIterator

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

Definition at line 49 of file SiPixelGainCalibrationOffline.h.

◆ Range

Definition at line 50 of file SiPixelGainCalibrationOffline.h.

◆ Registry

Definition at line 51 of file SiPixelGainCalibrationOffline.h.

◆ RegistryIterator

typedef Registry::const_iterator SiPixelGainCalibrationOffline::RegistryIterator

Definition at line 52 of file SiPixelGainCalibrationOffline.h.

Constructor & Destructor Documentation

◆ SiPixelGainCalibrationOffline() [1/2]

SiPixelGainCalibrationOffline::SiPixelGainCalibrationOffline ( )

Definition at line 9 of file SiPixelGainCalibrationOffline.cc.

References deadFlag_, Exception, and noisyFlag_.

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

◆ SiPixelGainCalibrationOffline() [2/2]

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

Definition at line 28 of file SiPixelGainCalibrationOffline.cc.

References deadFlag_, Exception, and noisyFlag_.

29  : minPed_(minPed),
30  maxPed_(maxPed),
31  minGain_(minGain),
32  maxGain_(maxGain),
35  deadFlag_(255),
36  noisyFlag_(254) {
37  if (deadFlag_ > 0xFF)
38  throw cms::Exception("GainCalibration Payload configuration error")
39  << "[SiPixelGainCalibrationOffline::SiPixelGainCalibrationOffline] Dead flag was set to " << deadFlag_
40  << ", and it must be set less than or equal to 255";
41  if (noisyFlag_ > 0xFF)
42  throw cms::Exception("GainCalibration Payload configuration error")
43  << "[SiPixelGainCalibrationOffline::SiPixelGainCalibrationOffline] Noisy flag was set to " << noisyFlag_
44  << ", and it must be set less than or equal to 255";
45 }

◆ ~SiPixelGainCalibrationOffline()

SiPixelGainCalibrationOffline::~SiPixelGainCalibrationOffline ( )
inline

Definition at line 57 of file SiPixelGainCalibrationOffline.h.

57 {}

Member Function Documentation

◆ decodeGain()

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

◆ decodePed()

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

◆ encodeGain()

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

Definition at line 215 of file SiPixelGainCalibrationOffline.cc.

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

Referenced by setDataGain().

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

◆ encodePed()

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

Definition at line 226 of file SiPixelGainCalibrationOffline.cc.

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

Referenced by setDataPedestal().

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

◆ getDetIds()

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

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

◆ getGain()

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

Definition at line 185 of file SiPixelGainCalibrationOffline.cc.

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

190  {
191  unsigned int lengthOfColumnData = (range.second - range.first) / nCols;
192  // determine what row averaged range we are in (i.e. ROC 1 or ROC 2)
193  unsigned int lengthOfAveragedDataInEachColumn = numberOfRowsToAverageOver_ + 1;
194  unsigned int numberOfAveragedDataBlocksToSkip = row / numberOfRowsToAverageOver_;
195 
196  // gain average is stored in the last location of current row averaged column data block
197  const unsigned int datum = *(range.first + col * lengthOfColumnData +
198  ((numberOfAveragedDataBlocksToSkip + 1) * lengthOfAveragedDataInEachColumn) - 1) &
199  0xFF;
200 
201  if (datum == deadFlag_)
202  isDeadColumn = true;
203  if (datum == noisyFlag_)
204  isNoisyColumn = true;
205 
206  int maxRow = lengthOfColumnData - (lengthOfColumnData % numberOfRowsToAverageOver_) - 1;
207  if (col >= nCols || row > maxRow) {
208  throw cms::Exception("CorruptedData")
209  << "[SiPixelGainCalibrationOffline::getPed] Pixel out of range: col " << col << " row " << row;
210  }
211 
212  return decodeGain(datum);
213 }
float decodeGain(unsigned int gain) const
col
Definition: cuy.py:1009

◆ getGainHigh()

double SiPixelGainCalibrationOffline::getGainHigh ( ) const
inline

Definition at line 80 of file SiPixelGainCalibrationOffline.h.

References maxGain_.

◆ getGainLow()

double SiPixelGainCalibrationOffline::getGainLow ( ) const
inline

Definition at line 79 of file SiPixelGainCalibrationOffline.h.

References minGain_.

◆ getNCols()

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

◆ getNumberOfRowsToAverageOver()

unsigned int SiPixelGainCalibrationOffline::getNumberOfRowsToAverageOver ( ) const
inline

◆ getPed()

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

Definition at line 158 of file SiPixelGainCalibrationOffline.cc.

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

159  {
160  unsigned int lengthOfColumnData = (range.second - range.first) / nCols;
161  // determine what row averaged range we are in (i.e. ROC 1 or ROC 2)
162  unsigned int lengthOfAveragedDataInEachColumn = numberOfRowsToAverageOver_ + 1;
163  unsigned int numberOfAveragedDataBlocksToSkip = row / numberOfRowsToAverageOver_;
164  unsigned int offSetInCorrectDataBlock = row % numberOfRowsToAverageOver_;
165 
166  const unsigned int datum =
167  *(range.first + col * lengthOfColumnData + numberOfAveragedDataBlocksToSkip * lengthOfAveragedDataInEachColumn +
168  offSetInCorrectDataBlock) &
169  0xFF;
170 
171  int maxRow = lengthOfColumnData - (lengthOfColumnData % numberOfRowsToAverageOver_) - 1;
172  if (col >= nCols || row > maxRow) {
173  throw cms::Exception("CorruptedData")
174  << "[SiPixelGainCalibrationOffline::getPed] Pixel out of range: col " << col << " row " << row;
175  }
176 
177  if (datum == deadFlag_)
178  isDead = true;
179  if (datum == noisyFlag_)
180  isNoisy = true;
181 
182  return decodePed(datum);
183 }
float decodePed(unsigned int ped) const
col
Definition: cuy.py:1009

◆ getPedHigh()

double SiPixelGainCalibrationOffline::getPedHigh ( ) const
inline

Definition at line 82 of file SiPixelGainCalibrationOffline.h.

References maxPed_.

◆ getPedLow()

double SiPixelGainCalibrationOffline::getPedLow ( ) const
inline

Definition at line 81 of file SiPixelGainCalibrationOffline.h.

References minPed_.

◆ getRange()

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

◆ getRangeAndNCols()

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

◆ initialize()

void SiPixelGainCalibrationOffline::initialize ( )
inline

Definition at line 59 of file SiPixelGainCalibrationOffline.h.

59 {}

◆ put()

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

Definition at line 47 of file SiPixelGainCalibrationOffline.cc.

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

Referenced by SiPixelGainCalibrationReadDQMFile::fillDatabase().

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

◆ serialize()

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

◆ setDataGain()

void SiPixelGainCalibrationOffline::setDataGain ( float  gain,
const int &  nRows,
std::vector< char > &  vped,
bool  thisColumnIsDead = false,
bool  thisColumnIsNoisy = false 
)

Definition at line 108 of file SiPixelGainCalibrationOffline.cc.

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

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

109  {
110  float theEncodedGain = 0;
111  if (!thisColumnIsDead && !thisColumnIsNoisy)
112  theEncodedGain = encodeGain(gain);
113 
114  unsigned int gain_ = (static_cast<unsigned int>(theEncodedGain)) & 0xFF;
115 
116  // if this whole column is dead, set a char based dead flag in the blob.
117  if (thisColumnIsDead)
118  gain_ = deadFlag_ & 0xFF;
119  if (thisColumnIsNoisy)
120  gain_ = noisyFlag_ & 0xFF;
121 
122  vped.resize(vped.size() + 1);
123  //check to make sure the column is being placed in the right place in the blob
124  if (nRows != (int)numberOfRowsToAverageOver_) {
125  throw cms::Exception("GainCalibration Payload configuration error")
126  << "[SiPixelGainCalibrationOffline::setDataGain] You are setting a gain averaged over nRows = " << nRows
127  << " where this payload is set ONLY to average over " << numberOfRowsToAverageOver_ << " nRows";
128  }
129 
130  if (vped.size() % (nRows + 1) != 0) {
131  throw cms::Exception("FillError")
132  << "[SiPixelGainCalibrationOffline::setDataGain] Column gain average (OR SETTING AN ENTIRE COLUMN DEAD/NOISY) "
133  "must be filled after the pedestal for each row has been added. An additional source of this error would be "
134  "setting a pixel dead/noisy AND setting its pedestal";
135  }
136  // insert in vector of char
137  ::memcpy((void*)(&vped[vped.size() - 1]), (void*)(&gain_), 1);
138 }
static const char gain_[]

◆ setDataPedestal()

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

Definition at line 140 of file SiPixelGainCalibrationOffline.cc.

References deadFlag_, encodePed(), noisyFlag_, and EcalCondDBWriter_cfi::pedestal.

Referenced by SiPixelGainCalibrationReadDQMFile::fillDatabase(), setDeadPixel(), and setNoisyPixel().

143  {
144  float theEncodedPedestal = encodePed(pedestal);
145 
146  unsigned int ped_ = (static_cast<unsigned int>(theEncodedPedestal)) & 0xFF;
147 
148  if (thisPixelIsDead)
149  ped_ = deadFlag_ & 0xFF;
150  if (thisPixelIsNoisy)
151  ped_ = noisyFlag_ & 0xFF;
152 
153  vped.resize(vped.size() + 1);
154  // insert in vector of char
155  ::memcpy((void*)(&vped[vped.size() - 1]), (void*)(&ped_), 1);
156 }

◆ setDeadColumn()

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

Definition at line 86 of file SiPixelGainCalibrationOffline.h.

References setDataGain().

Referenced by SiPixelGainCalibrationReadDQMFile::fillDatabase().

86  {
87  setDataGain(0 /*dummy value, not used*/, nRows, vped, true);
88  }
void setDataGain(float gain, const int &nRows, std::vector< char > &vped, bool thisColumnIsDead=false, bool thisColumnIsNoisy=false)

◆ setDeadPixel()

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

Definition at line 85 of file SiPixelGainCalibrationOffline.h.

References setDataPedestal().

Referenced by SiPixelGainCalibrationReadDQMFile::fillDatabase().

85 { setDataPedestal(0 /*dummy value, not used*/, vped, true); }
void setDataPedestal(float pedestal, std::vector< char > &vped, bool thisPixelIsDead=false, bool thisPixelIsNoisy=false)

◆ setNoisyColumn()

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

Definition at line 92 of file SiPixelGainCalibrationOffline.h.

References setDataGain().

92  {
93  setDataGain(0 /*dummy value, not used*/, nRows, vped, false, true);
94  }
void setDataGain(float gain, const int &nRows, std::vector< char > &vped, bool thisColumnIsDead=false, bool thisColumnIsNoisy=false)

◆ setNoisyPixel()

void SiPixelGainCalibrationOffline::setNoisyPixel ( std::vector< char > &  vped)
inline

Definition at line 91 of file SiPixelGainCalibrationOffline.h.

References setDataPedestal().

91 { setDataPedestal(0 /*dummy value, not used*/, vped, false, true); }
void setDataPedestal(float pedestal, std::vector< char > &vped, bool thisPixelIsDead=false, bool thisPixelIsNoisy=false)

Friends And Related Function Documentation

◆ boost::serialization::access

friend class boost::serialization::access
friend

Definition at line 122 of file SiPixelGainCalibrationOffline.h.

◆ cond::serialization::access

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

Definition at line 122 of file SiPixelGainCalibrationOffline.h.

Member Data Documentation

◆ deadFlag_

unsigned int SiPixelGainCalibrationOffline::deadFlag_
private

◆ indexes

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

Definition at line 112 of file SiPixelGainCalibrationOffline.h.

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

◆ maxGain_

float SiPixelGainCalibrationOffline::maxGain_
private

Definition at line 113 of file SiPixelGainCalibrationOffline.h.

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

◆ maxPed_

float SiPixelGainCalibrationOffline::maxPed_
private

Definition at line 113 of file SiPixelGainCalibrationOffline.h.

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

◆ minGain_

float SiPixelGainCalibrationOffline::minGain_
private

Definition at line 113 of file SiPixelGainCalibrationOffline.h.

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

◆ minPed_

float SiPixelGainCalibrationOffline::minPed_
private

Definition at line 113 of file SiPixelGainCalibrationOffline.h.

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

◆ nBinsToUseForEncoding_

unsigned int SiPixelGainCalibrationOffline::nBinsToUseForEncoding_
private

Definition at line 118 of file SiPixelGainCalibrationOffline.h.

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

◆ noisyFlag_

unsigned int SiPixelGainCalibrationOffline::noisyFlag_
private

◆ numberOfRowsToAverageOver_

unsigned int SiPixelGainCalibrationOffline::numberOfRowsToAverageOver_
private

◆ v_pedestals

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

Definition at line 111 of file SiPixelGainCalibrationOffline.h.

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