CMS 3D CMS Logo

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

#include <CondFormats/SiPixelObjects/src/SiPixelGainCalibration.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 &isDead, bool &isNoisy) 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 setData (float ped, float gain, std::vector< char > &vped, bool thisPixelIsDead=false, bool thisPixelIsNoisy=false)
 
void setDeadPixel (std::vector< char > &vped)
 
void setNoisyPixel (std::vector< char > &vped)
 
 SiPixelGainCalibration ()
 
 SiPixelGainCalibration (float minPed, float maxPed, float minGain, float maxGain)
 
 ~SiPixelGainCalibration ()
 

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. Store gain/pedestal information at pixel granularity

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

Definition at line 29 of file SiPixelGainCalibration.h.

Member Typedef Documentation

◆ ContainerIterator

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

Definition at line 50 of file SiPixelGainCalibration.h.

◆ Range

Definition at line 51 of file SiPixelGainCalibration.h.

◆ Registry

Definition at line 52 of file SiPixelGainCalibration.h.

◆ RegistryIterator

typedef Registry::const_iterator SiPixelGainCalibration::RegistryIterator

Definition at line 53 of file SiPixelGainCalibration.h.

Constructor & Destructor Documentation

◆ SiPixelGainCalibration() [1/2]

SiPixelGainCalibration::SiPixelGainCalibration ( )

Definition at line 9 of file SiPixelGainCalibration.cc.

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  << "[SiPixelGainCalibration::SiPixelGainCalibration] Dead flag was set to " << deadFlag_
21  << ", and it must be set less than or equal to 255";
22 }

References deadFlag_, and Exception.

◆ SiPixelGainCalibration() [2/2]

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

Definition at line 24 of file SiPixelGainCalibration.cc.

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

References deadFlag_, and Exception.

◆ ~SiPixelGainCalibration()

SiPixelGainCalibration::~SiPixelGainCalibration ( )
inline

Definition at line 58 of file SiPixelGainCalibration.h.

58 {}

Member Function Documentation

◆ decodeGain()

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

Definition at line 184 of file SiPixelGainCalibration.cc.

184  {
185  double precision = (maxGain_ - minGain_) / static_cast<float>(nBinsToUseForEncoding_);
186  float decodedGain = (float)(gain * precision + minGain_);
187  return decodedGain;
188 }

References dqmMemoryStats::float, PedestalClient_cfi::gain, maxGain_, minGain_, nBinsToUseForEncoding_, and common_cff::precision.

Referenced by getGain().

◆ decodePed()

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

Definition at line 178 of file SiPixelGainCalibration.cc.

178  {
179  double precision = (maxPed_ - minPed_) / static_cast<float>(nBinsToUseForEncoding_);
180  float decodedPed = (float)(ped * precision + minPed_);
181  return decodedPed;
182 }

References dqmMemoryStats::float, maxPed_, minPed_, nBinsToUseForEncoding_, and common_cff::precision.

Referenced by getPed().

◆ encodeGain()

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

Definition at line 156 of file SiPixelGainCalibration.cc.

156  {
157  if (gain < minGain_ || gain > maxGain_) {
158  throw cms::Exception("InsertFailure") << "[SiPixelGainCalibration::encodeGain] Trying to encode gain (" << gain
159  << ") out of range [" << minGain_ << "," << maxGain_ << "]\n";
160  } else {
161  double precision = (maxGain_ - minGain_) / static_cast<float>(nBinsToUseForEncoding_);
162  float encodedGain = (float)((gain - minGain_) / precision);
163  return encodedGain;
164  }
165 }

References Exception, dqmMemoryStats::float, PedestalClient_cfi::gain, maxGain_, minGain_, nBinsToUseForEncoding_, and common_cff::precision.

Referenced by setData().

◆ encodePed()

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

Definition at line 167 of file SiPixelGainCalibration.cc.

167  {
168  if (ped < minPed_ || ped > maxPed_) {
169  throw cms::Exception("InsertFailure") << "[SiPixelGainCalibration::encodePed] Trying to encode pedestal (" << ped
170  << ") out of range [" << minPed_ << "," << maxPed_ << "]\n";
171  } else {
172  double precision = (maxPed_ - minPed_) / static_cast<float>(nBinsToUseForEncoding_);
173  float encodedPed = (float)((ped - minPed_) / precision);
174  return encodedPed;
175  }
176 }

References Exception, dqmMemoryStats::float, maxPed_, minPed_, nBinsToUseForEncoding_, and common_cff::precision.

Referenced by setData().

◆ getDetIds()

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

Definition at line 91 of file SiPixelGainCalibration.cc.

91  {
92  // returns vector of DetIds in map
96  DetIds_.push_back(p->detid);
97  }
98 }

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

◆ getGain()

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

Definition at line 141 of file SiPixelGainCalibration.cc.

142  {
143  int nRows = (range.second - range.first) / 2 / nCols;
144  const unsigned int gain = *(range.first + (col * nRows + row) * 2) & 0xFF;
145  if (col >= nCols || row >= nRows) {
146  throw cms::Exception("CorruptedData")
147  << "[SiPixelGainCalibration::getPed] Pixel out of range: col " << col << " row " << row;
148  }
149  if (gain == deadFlag_)
150  isDead = true;
151  if (gain == noisyFlag_)
152  isNoisy = true;
153  return decodeGain(gain);
154 }

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

◆ getGainHigh()

double SiPixelGainCalibration::getGainHigh ( ) const
inline

Definition at line 70 of file SiPixelGainCalibration.h.

70 { return maxGain_; }

References maxGain_.

◆ getGainLow()

double SiPixelGainCalibration::getGainLow ( ) const
inline

Definition at line 69 of file SiPixelGainCalibration.h.

69 { return minGain_; }

References minGain_.

◆ getNCols()

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

Definition at line 59 of file SiPixelGainCalibration.cc.

59  {
60  // get number of columns of DetId
63  if (p == indexes.end() || p->detid != DetId)
64  return 0;
65  else
66  return p->ncols;
67 }

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

◆ getNumberOfRowsToAverageOver()

unsigned int SiPixelGainCalibration::getNumberOfRowsToAverageOver ( ) const
inline

Definition at line 68 of file SiPixelGainCalibration.h.

References numberOfRowsToAverageOver_.

◆ getPed()

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

Definition at line 126 of file SiPixelGainCalibration.cc.

127  {
128  int nRows = (range.second - range.first) / 2 / nCols;
129  const unsigned int ped = *(range.first + 1 + (col * nRows + row) * 2) & 0xFF;
130  if (col >= nCols || row >= nRows) {
131  throw cms::Exception("CorruptedData")
132  << "[SiPixelGainCalibration::getPed] Pixel out of range: col " << col << " row " << row;
133  }
134  if (ped == deadFlag_)
135  isDead = true;
136  if (ped == noisyFlag_)
137  isNoisy = true;
138  return decodePed(ped);
139 }

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

◆ getPedHigh()

double SiPixelGainCalibration::getPedHigh ( ) const
inline

Definition at line 72 of file SiPixelGainCalibration.h.

72 { return maxPed_; }

References maxPed_.

◆ getPedLow()

double SiPixelGainCalibration::getPedLow ( ) const
inline

Definition at line 71 of file SiPixelGainCalibration.h.

71 { return minPed_; }

References minPed_.

◆ getRange()

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

Definition at line 69 of file SiPixelGainCalibration.cc.

69  {
70  // get SiPixelGainCalibration Range of DetId
71 
74  if (p == indexes.end() || p->detid != DetId)
76  else
77  return SiPixelGainCalibration::Range(v_pedestals.begin() + p->ibegin, v_pedestals.begin() + p->iend);
78 }

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

◆ getRangeAndNCols()

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

Definition at line 80 of file SiPixelGainCalibration.cc.

81  {
84  if (p == indexes.end() || p->detid != DetId)
85  return std::make_pair(SiPixelGainCalibration::Range(v_pedestals.end(), v_pedestals.end()), 0);
86  else
87  return std::make_pair(SiPixelGainCalibration::Range(v_pedestals.begin() + p->ibegin, v_pedestals.begin() + p->iend),
88  p->ncols);
89 }

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

◆ initialize()

void SiPixelGainCalibration::initialize ( )
inline

Definition at line 60 of file SiPixelGainCalibration.h.

60 {}

◆ put()

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

Definition at line 39 of file SiPixelGainCalibration.cc.

39  {
40  // put in SiPixelGainCalibration of DetId
41 
42  Registry::iterator p =
44  if (p != indexes.end() && p->detid == DetId)
45  return false;
46 
47  size_t sd = input.second - input.first;
48  DetRegistry detregistry;
49  detregistry.detid = DetId;
50  detregistry.ncols = nCols;
51  detregistry.ibegin = v_pedestals.size();
52  detregistry.iend = v_pedestals.size() + sd;
53  indexes.insert(p, detregistry);
54 
55  v_pedestals.insert(v_pedestals.end(), input.first, input.second);
56  return true;
57 }

References SiPixelGainCalibration::DetRegistry::detid, SiPixelGainCalibration::DetRegistry::ibegin, SiPixelGainCalibration::DetRegistry::iend, indexes, input, cuda_std::lower_bound(), SiPixelGainCalibration::DetRegistry::ncols, AlCaHLTBitMon_ParallelJobs::p, sd, and v_pedestals.

◆ serialize()

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

◆ setData()

void SiPixelGainCalibration::setData ( float  ped,
float  gain,
std::vector< char > &  vped,
bool  thisPixelIsDead = false,
bool  thisPixelIsNoisy = false 
)

Definition at line 100 of file SiPixelGainCalibration.cc.

101  {
102  float theEncodedGain = 0;
103  float theEncodedPed = 0;
104  if (!isDeadPixel && !isNoisyPixel) {
105  theEncodedGain = encodeGain(gain);
106  theEncodedPed = encodePed(ped);
107  }
108 
109  unsigned int ped_ = (static_cast<unsigned int>(theEncodedPed)) & 0xFF;
110  unsigned int gain_ = (static_cast<unsigned int>(theEncodedGain)) & 0xFF;
111 
112  if (isDeadPixel) {
113  ped_ = deadFlag_ & 0xFF;
114  gain_ = deadFlag_ & 0xFF;
115  }
116  if (isNoisyPixel) {
117  ped_ = noisyFlag_ & 0xFF;
118  gain_ = noisyFlag_ & 0xFF;
119  }
120  unsigned int data = (ped_ << 8) | gain_;
121  vped.resize(vped.size() + 2);
122  // insert in vector of char
123  ::memcpy((void*)(&vped[vped.size() - 2]), (void*)(&data), 2);
124 }

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

Referenced by setDeadPixel(), and setNoisyPixel().

◆ setDeadPixel()

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

Definition at line 78 of file SiPixelGainCalibration.h.

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

References setData().

◆ setNoisyPixel()

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

Definition at line 79 of file SiPixelGainCalibration.h.

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

References setData().

Friends And Related Function Documentation

◆ boost::serialization::access

friend class boost::serialization::access
friend

Definition at line 101 of file SiPixelGainCalibration.h.

◆ cond::serialization::access

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

Definition at line 101 of file SiPixelGainCalibration.h.

Member Data Documentation

◆ deadFlag_

unsigned int SiPixelGainCalibration::deadFlag_
private

Definition at line 98 of file SiPixelGainCalibration.h.

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

◆ indexes

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

Definition at line 91 of file SiPixelGainCalibration.h.

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

◆ maxGain_

float SiPixelGainCalibration::maxGain_
private

Definition at line 92 of file SiPixelGainCalibration.h.

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

◆ maxPed_

float SiPixelGainCalibration::maxPed_
private

Definition at line 92 of file SiPixelGainCalibration.h.

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

◆ minGain_

float SiPixelGainCalibration::minGain_
private

Definition at line 92 of file SiPixelGainCalibration.h.

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

◆ minPed_

float SiPixelGainCalibration::minPed_
private

Definition at line 92 of file SiPixelGainCalibration.h.

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

◆ nBinsToUseForEncoding_

unsigned int SiPixelGainCalibration::nBinsToUseForEncoding_
private

Definition at line 97 of file SiPixelGainCalibration.h.

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

◆ noisyFlag_

unsigned int SiPixelGainCalibration::noisyFlag_
private

Definition at line 99 of file SiPixelGainCalibration.h.

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

◆ numberOfRowsToAverageOver_

unsigned int SiPixelGainCalibration::numberOfRowsToAverageOver_
private

Definition at line 95 of file SiPixelGainCalibration.h.

Referenced by getNumberOfRowsToAverageOver().

◆ v_pedestals

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

Definition at line 90 of file SiPixelGainCalibration.h.

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

FastTimerService_cff.range
range
Definition: FastTimerService_cff.py:34
input
static const std::string input
Definition: EdmProvDump.cc:48
SiPixelGainCalibration::decodePed
float decodePed(unsigned int ped) const
Definition: SiPixelGainCalibration.cc:178
SiPixelGainCalibration::encodePed
float encodePed(const float &ped)
Definition: SiPixelGainCalibration.cc:167
dqmMemoryStats.float
float
Definition: dqmMemoryStats.py:127
AlCaHLTBitMon_ParallelJobs.p
p
Definition: AlCaHLTBitMon_ParallelJobs.py:153
cuy.col
col
Definition: cuy.py:1010
SiPixelGainCalibration::RegistryIterator
Registry::const_iterator RegistryIterator
Definition: SiPixelGainCalibration.h:53
SiPixelGainCalibration::minGain_
float minGain_
Definition: SiPixelGainCalibration.h:92
end
#define end
Definition: vmac.h:39
SiPixelGainCalibration::Range
std::pair< ContainerIterator, ContainerIterator > Range
Definition: SiPixelGainCalibration.h:51
DetId
Definition: DetId.h:17
SiPixelGainCalibration::setData
void setData(float ped, float gain, std::vector< char > &vped, bool thisPixelIsDead=false, bool thisPixelIsNoisy=false)
Definition: SiPixelGainCalibration.cc:100
SiPixelGainCalibration::decodeGain
float decodeGain(unsigned int gain) const
Definition: SiPixelGainCalibration.cc:184
SiPixelGainCalibration::v_pedestals
std::vector< char > v_pedestals
Definition: SiPixelGainCalibration.h:90
SiPixelGainCalibration::noisyFlag_
unsigned int noisyFlag_
Definition: SiPixelGainCalibration.h:99
SiPixelGainCalibration::nBinsToUseForEncoding_
unsigned int nBinsToUseForEncoding_
Definition: SiPixelGainCalibration.h:97
cuda_std::lower_bound
__host__ constexpr __device__ RandomIt lower_bound(RandomIt first, RandomIt last, const T &value, Compare comp={})
Definition: cudastdAlgorithm.h:27
SiPixelGainCalibration::encodeGain
float encodeGain(const float &gain)
Definition: SiPixelGainCalibration.cc:156
common_cff.precision
precision
Definition: common_cff.py:44
sistrip::extrainfo::gain_
static const char gain_[]
Definition: ConstantsForDqm.h:39
SiPixelGainCalibration::indexes
std::vector< DetRegistry > indexes
Definition: SiPixelGainCalibration.h:91
SiPixelGainCalibration::maxPed_
float maxPed_
Definition: SiPixelGainCalibration.h:92
PedestalClient_cfi.gain
gain
Definition: PedestalClient_cfi.py:37
SiPixelGainCalibration::maxGain_
float maxGain_
Definition: SiPixelGainCalibration.h:92
Exception
Definition: hltDiff.cc:246
SiPixelGainCalibration::deadFlag_
unsigned int deadFlag_
Definition: SiPixelGainCalibration.h:98
data
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:79
SiPixelGainCalibration::minPed_
float minPed_
Definition: SiPixelGainCalibration.h:92
sd
double sd
Definition: CascadeWrapper.h:113
SiPixelGainCalibration::numberOfRowsToAverageOver_
unsigned int numberOfRowsToAverageOver_
Definition: SiPixelGainCalibration.h:95
SiPixelGainCalibration::StrictWeakOrdering
Definition: SiPixelGainCalibration.h:45
begin
#define begin
Definition: vmac.h:32