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

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

Definition at line 51 of file SiPixelGainCalibrationOffline.h.

Definition at line 52 of file SiPixelGainCalibrationOffline.h.

Definition at line 53 of file SiPixelGainCalibrationOffline.h.

typedef Registry::const_iterator SiPixelGainCalibrationOffline::RegistryIterator

Definition at line 54 of file SiPixelGainCalibrationOffline.h.

Constructor & Destructor Documentation

SiPixelGainCalibrationOffline::SiPixelGainCalibrationOffline ( )

Definition at line 9 of file SiPixelGainCalibrationOffline.cc.

References deadFlag_, Exception, and noisyFlag_.

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  << "[SiPixelGainCalibrationOffline::SiPixelGainCalibrationOffline] Dead flag was set to " << deadFlag_ << ", 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_ << ", and it must be set less than or equal to 255";
25 }
SiPixelGainCalibrationOffline::SiPixelGainCalibrationOffline ( float  minPed,
float  maxPed,
float  minGain,
float  maxGain 
)

Definition at line 27 of file SiPixelGainCalibrationOffline.cc.

References deadFlag_, Exception, and noisyFlag_.

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

Definition at line 59 of file SiPixelGainCalibrationOffline.h.

59 {}

Member Function Documentation

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

Definition at line 222 of file SiPixelGainCalibrationOffline.cc.

References objects.autophobj::float, maxPed_, minPed_, nBinsToUseForEncoding_, and common_cff::precision.

Referenced by getPed(), and setNoisyColumn().

222  {
223 
224  double precision = (maxPed_-minPed_)/static_cast<float>(nBinsToUseForEncoding_);
225  float decodedPed = (float)(ped*precision + minPed_);
226  return decodedPed;
227 
228 }
float SiPixelGainCalibrationOffline::encodeGain ( const float &  gain)
private

Definition at line 196 of file SiPixelGainCalibrationOffline.cc.

References Exception, objects.autophobj::float, maxGain_, minGain_, nBinsToUseForEncoding_, and common_cff::precision.

Referenced by setDataGain(), and setNoisyColumn().

196  {
197 
198  if(gain < minGain_ || gain > maxGain_ ) {
199  throw cms::Exception("InsertFailure")
200  << "[SiPixelGainCalibrationOffline::encodeGain] Trying to encode gain (" << gain << ") out of range [" << minGain_ << "," << maxGain_ << "]\n";
201  } else {
202  double precision = (maxGain_-minGain_)/static_cast<float>(nBinsToUseForEncoding_);
203  float encodedGain = (float)((gain-minGain_)/precision);
204  return encodedGain;
205  }
206 
207 }
float SiPixelGainCalibrationOffline::encodePed ( const float &  ped)
private

Definition at line 209 of file SiPixelGainCalibrationOffline.cc.

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

Referenced by setDataPedestal(), and setNoisyColumn().

209  {
210 
211  if(ped < minPed_ || ped > maxPed_ ) {
212  throw cms::Exception("InsertFailure")
213  << "[SiPixelGainCalibrationOffline::encodePed] Trying to encode pedestal (" << ped << ") out of range [" << minPed_ << "," << maxPed_ << "]\n";
214  } else {
215  double precision = (maxPed_-minPed_)/static_cast<float>(nBinsToUseForEncoding_);
216  float encodedPed = (float)((ped-minPed_)/precision);
217  return encodedPed;
218  }
219 
220 }
void SiPixelGainCalibrationOffline::getDetIds ( std::vector< uint32_t > &  DetIds_) const

Definition at line 93 of file SiPixelGainCalibrationOffline.cc.

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

Referenced by initialize().

93  {
94  // returns vector of DetIds in map
98  DetIds_.push_back(p->detid);
99  }
100 }
#define end
Definition: vmac.h:39
#define begin
Definition: vmac.h:32
float SiPixelGainCalibrationOffline::getGain ( const int &  col,
const int &  row,
const Range range,
const int &  nCols,
bool &  isDeadColumn,
bool &  isNoisyColumn 
) const

Definition at line 173 of file SiPixelGainCalibrationOffline.cc.

References SiPixelGainCalibrationOffline::DecodingStructure::datum, deadFlag_, decodeGain(), Exception, noisyFlag_, numberOfRowsToAverageOver_, and alignCSCRings::s.

Referenced by setNoisyColumn().

173  {
174 
175  unsigned int lengthOfColumnData = (range.second-range.first)/nCols;
176  //determine what row averaged range we are in (i.e. ROC 1 or ROC 2)
177  unsigned int lengthOfAveragedDataInEachColumn = numberOfRowsToAverageOver_ + 1;
178  unsigned int numberOfAveragedDataBlocksToSkip = row / numberOfRowsToAverageOver_;
179 
180  // gain average is stored in the last location of current row averaged column data block
181  const DecodingStructure & s = (const DecodingStructure & ) *(range.first+(col)*(lengthOfColumnData) + ( (numberOfAveragedDataBlocksToSkip+1) * lengthOfAveragedDataInEachColumn) - 1);
182 
183  if ((s.datum & 0xFF) == deadFlag_)
184  isDeadColumn = true;
185  if ((s.datum & 0xFF) == noisyFlag_)
186  isNoisyColumn = true;
187 
188  int maxRow = lengthOfColumnData - (lengthOfColumnData % numberOfRowsToAverageOver_) - 1;
189  if (col >= nCols || row > maxRow){
190  throw cms::Exception("CorruptedData")
191  << "[SiPixelGainCalibrationOffline::getPed] Pixel out of range: col " << col << " row " << row;
192  }
193  return decodeGain(s.datum & 0xFF);
194 }
float decodeGain(unsigned int gain) const
col
Definition: cuy.py:1010
double SiPixelGainCalibrationOffline::getGainHigh ( ) const
inline

Definition at line 76 of file SiPixelGainCalibrationOffline.h.

References maxGain_.

double SiPixelGainCalibrationOffline::getGainLow ( ) const
inline

Definition at line 75 of file SiPixelGainCalibrationOffline.h.

References minGain_.

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

Definition at line 64 of file SiPixelGainCalibrationOffline.cc.

References indexes, and AlCaHLTBitMon_ParallelJobs::p.

Referenced by initialize().

64  {
65  // get number of columns of DetId
67  if (p==indexes.end()|| p->detid!=DetId)
68  return 0;
69  else
70  return p->ncols;
71 }
Definition: DetId.h:18
unsigned int SiPixelGainCalibrationOffline::getNumberOfRowsToAverageOver ( ) const
inline
float SiPixelGainCalibrationOffline::getPed ( const int &  col,
const int &  row,
const Range range,
const int &  nCols,
bool &  isDead,
bool &  isNoisy 
) const

Definition at line 149 of file SiPixelGainCalibrationOffline.cc.

References SiPixelGainCalibrationOffline::DecodingStructure::datum, deadFlag_, decodePed(), Exception, noisyFlag_, numberOfRowsToAverageOver_, and alignCSCRings::s.

Referenced by setNoisyColumn().

149  {
150 
151  unsigned int lengthOfColumnData = (range.second-range.first)/nCols;
152  //determine what row averaged range we are in (i.e. ROC 1 or ROC 2)
153  unsigned int lengthOfAveragedDataInEachColumn = numberOfRowsToAverageOver_ + 1;
154  unsigned int numberOfAveragedDataBlocksToSkip = row / numberOfRowsToAverageOver_;
155  unsigned int offSetInCorrectDataBlock = row % numberOfRowsToAverageOver_;
156 
157  const DecodingStructure & s = (const DecodingStructure & ) *(range.first + col*(lengthOfColumnData) + (numberOfAveragedDataBlocksToSkip * lengthOfAveragedDataInEachColumn) + offSetInCorrectDataBlock);
158 
159  int maxRow = lengthOfColumnData - (lengthOfColumnData % numberOfRowsToAverageOver_) - 1;
160  if (col >= nCols || row > maxRow){
161  throw cms::Exception("CorruptedData")
162  << "[SiPixelGainCalibrationOffline::getPed] Pixel out of range: col " << col << " row " << row;
163  }
164 
165  if ((s.datum & 0xFF) == deadFlag_)
166  isDead = true;
167  if ((s.datum & 0xFF) == noisyFlag_)
168  isNoisy = true;
169 
170  return decodePed(s.datum & 0xFF);
171 }
col
Definition: cuy.py:1010
float decodePed(unsigned int ped) const
double SiPixelGainCalibrationOffline::getPedHigh ( ) const
inline

Definition at line 78 of file SiPixelGainCalibrationOffline.h.

References maxPed_.

double SiPixelGainCalibrationOffline::getPedLow ( ) const
inline

Definition at line 77 of file SiPixelGainCalibrationOffline.h.

References minPed_.

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

Definition at line 73 of file SiPixelGainCalibrationOffline.cc.

References indexes, AlCaHLTBitMon_ParallelJobs::p, and v_pedestals.

Referenced by initialize().

73  {
74  // get SiPixelGainCalibrationOffline Range of DetId
75 
77  if (p==indexes.end()|| p->detid!=DetId)
79  else
80  return SiPixelGainCalibrationOffline::Range(v_pedestals.begin()+p->ibegin,v_pedestals.begin()+p->iend);
81 }
std::pair< ContainerIterator, ContainerIterator > Range
Definition: DetId.h:18
const std::pair< const SiPixelGainCalibrationOffline::Range, const int > SiPixelGainCalibrationOffline::getRangeAndNCols ( const uint32_t &  detID) const

Definition at line 84 of file SiPixelGainCalibrationOffline.cc.

References indexes, AlCaHLTBitMon_ParallelJobs::p, and v_pedestals.

Referenced by initialize().

84  {
86  if (p==indexes.end()|| p->detid!=DetId)
87  return std::make_pair(SiPixelGainCalibrationOffline::Range(v_pedestals.end(),v_pedestals.end()), 0);
88  else
89  return std::make_pair(SiPixelGainCalibrationOffline::Range(v_pedestals.begin()+p->ibegin,v_pedestals.begin()+p->iend), p->ncols);
90 }
std::pair< ContainerIterator, ContainerIterator > Range
Definition: DetId.h:18
void SiPixelGainCalibrationOffline::initialize ( )
inline
bool SiPixelGainCalibrationOffline::put ( const uint32_t &  detID,
Range  input,
const int &  nCols 
)

Definition at line 45 of file SiPixelGainCalibrationOffline.cc.

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

Referenced by initialize(), and SiPixelFakeGainOfflineESSource::produce().

45  {
46  // put in SiPixelGainCalibrationOffline of DetId
47 
48  Registry::iterator p = std::lower_bound(indexes.begin(),indexes.end(),DetId,SiPixelGainCalibrationOffline::StrictWeakOrdering());
49  if (p!=indexes.end() && p->detid==DetId)
50  return false;
51 
52  size_t sd= input.second-input.first;
53  DetRegistry detregistry;
54  detregistry.detid=DetId;
55  detregistry.ncols=nCols;
56  detregistry.ibegin=v_pedestals.size();
57  detregistry.iend=v_pedestals.size()+sd;
58  indexes.insert(p,detregistry);
59 
60  v_pedestals.insert(v_pedestals.end(),input.first,input.second);
61  return true;
62 }
static std::string const input
Definition: EdmProvDump.cc:48
Definition: DetId.h:18
double sd
template<class Archive >
void SiPixelGainCalibrationOffline::serialize ( Archive &  ar,
const unsigned int  version 
)
private
void SiPixelGainCalibrationOffline::setDataGain ( float  gain,
const int &  nRows,
std::vector< char > &  vped,
bool  thisColumnIsDead = false,
bool  thisColumnIsNoisy = false 
)

Definition at line 102 of file SiPixelGainCalibrationOffline.cc.

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

Referenced by initialize(), SiPixelFakeGainOfflineESSource::produce(), setDeadColumn(), and setNoisyColumn().

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

Definition at line 133 of file SiPixelGainCalibrationOffline.cc.

References deadFlag_, encodePed(), and noisyFlag_.

Referenced by initialize(), SiPixelFakeGainOfflineESSource::produce(), setDeadPixel(), and setNoisyPixel().

133  {
134 
135  float theEncodedPedestal = encodePed(pedestal);
136 
137  unsigned int ped_ = (static_cast<unsigned int>(theEncodedPedestal)) & 0xFF;
138 
139  if (thisPixelIsDead)
140  ped_ = deadFlag_ & 0xFF;
141  if (thisPixelIsNoisy)
142  ped_ = noisyFlag_ & 0xFF;
143 
144  vped.resize(vped.size()+1);
145  // insert in vector of char
146  ::memcpy((void*)(&vped[vped.size()-1]),(void*)(&ped_),1);
147 }
void SiPixelGainCalibrationOffline::setDeadColumn ( const int &  nRows,
std::vector< char > &  vped 
)
inline

Definition at line 82 of file SiPixelGainCalibrationOffline.h.

References setDataGain().

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

Definition at line 81 of file SiPixelGainCalibrationOffline.h.

References setDataPedestal().

81 { setDataPedestal(0 /*dummy value, not used*/, vped, true ); }
void setDataPedestal(float pedestal, std::vector< char > &vped, bool thisPixelIsDead=false, bool thisPixelIsNoisy=false)
void SiPixelGainCalibrationOffline::setNoisyColumn ( const int &  nRows,
std::vector< char > &  vped 
)
inline

Definition at line 86 of file SiPixelGainCalibrationOffline.h.

References cuy::col, decodeGain(), decodePed(), encodeGain(), encodePed(), getGain(), getPed(), and setDataGain().

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

Definition at line 85 of file SiPixelGainCalibrationOffline.h.

References setDataPedestal().

85 { 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

friend class boost::serialization::access
friend

Definition at line 110 of file SiPixelGainCalibrationOffline.h.

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

Definition at line 110 of file SiPixelGainCalibrationOffline.h.

Member Data Documentation

unsigned int SiPixelGainCalibrationOffline::deadFlag_
private
std::vector<DetRegistry> SiPixelGainCalibrationOffline::indexes
private

Definition at line 101 of file SiPixelGainCalibrationOffline.h.

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

float SiPixelGainCalibrationOffline::maxGain_
private

Definition at line 102 of file SiPixelGainCalibrationOffline.h.

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

float SiPixelGainCalibrationOffline::maxPed_
private

Definition at line 102 of file SiPixelGainCalibrationOffline.h.

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

float SiPixelGainCalibrationOffline::minGain_
private

Definition at line 102 of file SiPixelGainCalibrationOffline.h.

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

float SiPixelGainCalibrationOffline::minPed_
private

Definition at line 102 of file SiPixelGainCalibrationOffline.h.

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

unsigned int SiPixelGainCalibrationOffline::nBinsToUseForEncoding_
private

Definition at line 105 of file SiPixelGainCalibrationOffline.h.

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

unsigned int SiPixelGainCalibrationOffline::noisyFlag_
private
unsigned int SiPixelGainCalibrationOffline::numberOfRowsToAverageOver_
private
std::vector<char> SiPixelGainCalibrationOffline::v_pedestals
private

Definition at line 100 of file SiPixelGainCalibrationOffline.h.

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