CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Classes | Public Types | Public Member Functions | Private Member Functions | Private Attributes
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,
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 &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
 
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)
 
virtual ~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)
 

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

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

Definition at line 27 of file SiPixelGainCalibration.h.

Member Typedef Documentation

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

Definition at line 49 of file SiPixelGainCalibration.h.

Definition at line 50 of file SiPixelGainCalibration.h.

Definition at line 51 of file SiPixelGainCalibration.h.

typedef Registry::const_iterator SiPixelGainCalibration::RegistryIterator

Definition at line 52 of file SiPixelGainCalibration.h.

Constructor & Destructor Documentation

SiPixelGainCalibration::SiPixelGainCalibration ( )

Definition at line 9 of file SiPixelGainCalibration.cc.

References deadFlag_, and edm::hlt::Exception.

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

Definition at line 24 of file SiPixelGainCalibration.cc.

References deadFlag_, and edm::hlt::Exception.

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

Definition at line 57 of file SiPixelGainCalibration.h.

57 {};

Member Function Documentation

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

Definition at line 188 of file SiPixelGainCalibration.cc.

References maxGain_, minGain_, and nBinsToUseForEncoding_.

Referenced by getGain().

188  {
189 
190  double precision = (maxGain_-minGain_)/static_cast<float>(nBinsToUseForEncoding_);
191  float decodedGain = (float)(gain*precision + minGain_);
192  return decodedGain;
193 
194 }
float SiPixelGainCalibration::decodePed ( unsigned int  ped) const
private

Definition at line 180 of file SiPixelGainCalibration.cc.

References maxPed_, minPed_, and nBinsToUseForEncoding_.

Referenced by getPed().

180  {
181 
182  double precision = (maxPed_-minPed_)/static_cast<float>(nBinsToUseForEncoding_);
183  float decodedPed = (float)(ped*precision + minPed_);
184  return decodedPed;
185 
186 }
float SiPixelGainCalibration::encodeGain ( const float &  gain)
private

Definition at line 154 of file SiPixelGainCalibration.cc.

References edm::hlt::Exception, maxGain_, minGain_, and nBinsToUseForEncoding_.

Referenced by setData().

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

Definition at line 167 of file SiPixelGainCalibration.cc.

References edm::hlt::Exception, maxPed_, minPed_, and nBinsToUseForEncoding_.

Referenced by setData().

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

Definition at line 87 of file SiPixelGainCalibration.cc.

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

87  {
88  // returns vector of DetIds in map
91  for (SiPixelGainCalibration::RegistryIterator p=begin; p != end; ++p) {
92  DetIds_.push_back(p->detid);
93  }
94 }
std::vector< DetRegistry > indexes
#define end
Definition: vmac.h:38
Registry::const_iterator RegistryIterator
#define begin
Definition: vmac.h:31
float SiPixelGainCalibration::getGain ( const int &  col,
const int &  row,
const Range range,
const int &  nCols,
bool &  isDead,
bool &  isNoisy 
) const

Definition at line 139 of file SiPixelGainCalibration.cc.

References deadFlag_, decodeGain(), edm::hlt::Exception, SiPixelGainCalibration::DecodingStructure::gain, noisyFlag_, and alignCSCRings::s.

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

Definition at line 67 of file SiPixelGainCalibration.h.

References maxGain_.

67 { return maxGain_; }
double SiPixelGainCalibration::getGainLow ( ) const
inline

Definition at line 66 of file SiPixelGainCalibration.h.

References minGain_.

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

Definition at line 58 of file SiPixelGainCalibration.cc.

References indexes, and AlCaHLTBitMon_ParallelJobs::p.

58  {
59  // get number of columns of DetId
61  if (p==indexes.end()|| p->detid!=DetId)
62  return 0;
63  else
64  return p->ncols;
65 }
std::vector< DetRegistry > indexes
Definition: DetId.h:20
Registry::const_iterator RegistryIterator
unsigned int SiPixelGainCalibration::getNumberOfRowsToAverageOver ( ) const
inline

Definition at line 65 of file SiPixelGainCalibration.h.

References numberOfRowsToAverageOver_.

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

Definition at line 124 of file SiPixelGainCalibration.cc.

References deadFlag_, decodePed(), edm::hlt::Exception, noisyFlag_, SiPixelGainCalibration::DecodingStructure::ped, and alignCSCRings::s.

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

Definition at line 69 of file SiPixelGainCalibration.h.

References maxPed_.

69 { return maxPed_; }
double SiPixelGainCalibration::getPedLow ( ) const
inline

Definition at line 68 of file SiPixelGainCalibration.h.

References minPed_.

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

Definition at line 67 of file SiPixelGainCalibration.cc.

References indexes, AlCaHLTBitMon_ParallelJobs::p, and v_pedestals.

67  {
68  // get SiPixelGainCalibration Range of DetId
69 
71  if (p==indexes.end()|| p->detid!=DetId)
73  else
74  return SiPixelGainCalibration::Range(v_pedestals.begin()+p->ibegin,v_pedestals.begin()+p->iend);
75 }
std::vector< char > v_pedestals
std::vector< DetRegistry > indexes
Definition: DetId.h:20
Registry::const_iterator RegistryIterator
std::pair< ContainerIterator, ContainerIterator > Range
const std::pair< const SiPixelGainCalibration::Range, const int > SiPixelGainCalibration::getRangeAndNCols ( const uint32_t &  detID) const

Definition at line 78 of file SiPixelGainCalibration.cc.

References indexes, AlCaHLTBitMon_ParallelJobs::p, and v_pedestals.

78  {
80  if (p==indexes.end()|| p->detid!=DetId)
81  return std::make_pair(SiPixelGainCalibration::Range(v_pedestals.end(),v_pedestals.end()), 0);
82  else
83  return std::make_pair(SiPixelGainCalibration::Range(v_pedestals.begin()+p->ibegin,v_pedestals.begin()+p->iend), p->ncols);
84 }
std::vector< char > v_pedestals
std::vector< DetRegistry > indexes
Definition: DetId.h:20
Registry::const_iterator RegistryIterator
std::pair< ContainerIterator, ContainerIterator > Range
bool SiPixelGainCalibration::put ( const uint32_t &  detID,
Range  input,
const int &  nCols 
)

Definition at line 39 of file SiPixelGainCalibration.cc.

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

39  {
40  // put in SiPixelGainCalibration of DetId
41 
42  Registry::iterator p = std::lower_bound(indexes.begin(),indexes.end(),DetId,SiPixelGainCalibration::StrictWeakOrdering());
43  if (p!=indexes.end() && p->detid==DetId)
44  return false;
45 
46  size_t sd= input.second-input.first;
47  DetRegistry detregistry;
48  detregistry.detid=DetId;
49  detregistry.ncols=nCols;
50  detregistry.ibegin=v_pedestals.size();
51  detregistry.iend=v_pedestals.size()+sd;
52  indexes.insert(p,detregistry);
53 
54  v_pedestals.insert(v_pedestals.end(),input.first,input.second);
55  return true;
56 }
std::vector< char > v_pedestals
std::vector< DetRegistry > indexes
Definition: DetId.h:20
double sd
void SiPixelGainCalibration::setData ( float  ped,
float  gain,
std::vector< char > &  vped,
bool  thisPixelIsDead = false,
bool  thisPixelIsNoisy = false 
)

Definition at line 96 of file SiPixelGainCalibration.cc.

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

Referenced by setDeadPixel(), and setNoisyPixel().

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

Definition at line 74 of file SiPixelGainCalibration.h.

References setData().

74 { setData(0, 0, /*dummy values, not used*/ vped, true , false ); }
void setData(float ped, float gain, std::vector< char > &vped, bool thisPixelIsDead=false, bool thisPixelIsNoisy=false)
void SiPixelGainCalibration::setNoisyPixel ( std::vector< char > &  vped)
inline

Definition at line 75 of file SiPixelGainCalibration.h.

References setData().

75 { setData(0, 0, /*dummy values, not used*/ vped, false , true ); }
void setData(float ped, float gain, std::vector< char > &vped, bool thisPixelIsDead=false, bool thisPixelIsNoisy=false)

Member Data Documentation

unsigned int SiPixelGainCalibration::deadFlag_
private

Definition at line 93 of file SiPixelGainCalibration.h.

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

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

Definition at line 88 of file SiPixelGainCalibration.h.

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

float SiPixelGainCalibration::maxGain_
private

Definition at line 89 of file SiPixelGainCalibration.h.

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

float SiPixelGainCalibration::maxPed_
private

Definition at line 89 of file SiPixelGainCalibration.h.

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

float SiPixelGainCalibration::minGain_
private

Definition at line 89 of file SiPixelGainCalibration.h.

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

float SiPixelGainCalibration::minPed_
private

Definition at line 89 of file SiPixelGainCalibration.h.

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

unsigned int SiPixelGainCalibration::nBinsToUseForEncoding_
private

Definition at line 92 of file SiPixelGainCalibration.h.

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

unsigned int SiPixelGainCalibration::noisyFlag_
private

Definition at line 94 of file SiPixelGainCalibration.h.

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

unsigned int SiPixelGainCalibration::numberOfRowsToAverageOver_
private

Definition at line 91 of file SiPixelGainCalibration.h.

Referenced by getNumberOfRowsToAverageOver().

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

Definition at line 87 of file SiPixelGainCalibration.h.

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