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

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 &isDeadColumn, bool &isNoisyColumn) 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 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)
 
virtual ~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)
 

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 for use at HLT. Stores only average gain and average pedestal per column.

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

Definition at line 27 of file SiPixelGainCalibrationForHLT.h.

Member Typedef Documentation

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

Definition at line 48 of file SiPixelGainCalibrationForHLT.h.

Definition at line 49 of file SiPixelGainCalibrationForHLT.h.

Definition at line 50 of file SiPixelGainCalibrationForHLT.h.

typedef Registry::const_iterator SiPixelGainCalibrationForHLT::RegistryIterator

Definition at line 51 of file SiPixelGainCalibrationForHLT.h.

Constructor & Destructor Documentation

SiPixelGainCalibrationForHLT::SiPixelGainCalibrationForHLT ( )

Definition at line 9 of file SiPixelGainCalibrationForHLT.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  << "[SiPixelGainCalibrationHLT::SiPixelGainCalibrationHLT] Dead flag was set to " << deadFlag_ << ", and it must be set less than or equal to 255";
22 }
SiPixelGainCalibrationForHLT::SiPixelGainCalibrationForHLT ( float  minPed,
float  maxPed,
float  minGain,
float  maxGain 
)

Definition at line 24 of file SiPixelGainCalibrationForHLT.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  << "[SiPixelGainCalibrationHLT::SiPixelGainCalibrationHLT] Dead flag was set to " << deadFlag_ << ", and it must be set less than or equal to 255";
37 }
virtual SiPixelGainCalibrationForHLT::~SiPixelGainCalibrationForHLT ( )
inlinevirtual

Definition at line 56 of file SiPixelGainCalibrationForHLT.h.

56 {};

Member Function Documentation

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

Definition at line 206 of file SiPixelGainCalibrationForHLT.cc.

References maxGain_, minGain_, and nBinsToUseForEncoding_.

Referenced by getGain().

206  {
207 
208  double precision = (maxGain_-minGain_)/static_cast<float>(nBinsToUseForEncoding_);
209  float decodedGain = (float)(gain*precision + minGain_);
210  return decodedGain;
211 
212 }
float SiPixelGainCalibrationForHLT::decodePed ( unsigned int  ped) const
private

Definition at line 198 of file SiPixelGainCalibrationForHLT.cc.

References maxPed_, minPed_, and nBinsToUseForEncoding_.

Referenced by getPed().

198  {
199 
200  double precision = (maxPed_-minPed_)/static_cast<float>(nBinsToUseForEncoding_);
201  float decodedPed = (float)(ped*precision + minPed_);
202  return decodedPed;
203 
204 }
float SiPixelGainCalibrationForHLT::encodeGain ( const float &  gain)
private

Definition at line 172 of file SiPixelGainCalibrationForHLT.cc.

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

Referenced by setData().

172  {
173 
174  if(gain < minGain_ || gain > maxGain_ ) {
175  throw cms::Exception("InsertFailure")
176  << "[SiPixelGainCalibrationForHLT::encodeGain] Trying to encode gain (" << gain << ") out of range [" << minGain_ << "," << maxGain_ << "]\n";
177  } else {
178  double precision = (maxGain_-minGain_)/static_cast<float>(nBinsToUseForEncoding_);
179  float encodedGain = (float)((gain-minGain_)/precision);
180  return encodedGain;
181  }
182 
183 }
float SiPixelGainCalibrationForHLT::encodePed ( const float &  ped)
private

Definition at line 185 of file SiPixelGainCalibrationForHLT.cc.

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

Referenced by setData().

185  {
186 
187  if(ped < minPed_ || ped > maxPed_ ) {
188  throw cms::Exception("InsertFailure")
189  << "[SiPixelGainCalibrationForHLT::encodePed] Trying to encode pedestal (" << ped << ") out of range [" << minPed_ << "," << maxPed_ << "]\n";
190  } else {
191  double precision = (maxPed_-minPed_)/static_cast<float>(nBinsToUseForEncoding_);
192  float encodedPed = (float)((ped-minPed_)/precision);
193  return encodedPed;
194  }
195 
196 }
void SiPixelGainCalibrationForHLT::getDetIds ( std::vector< uint32_t > &  DetIds_) const

Definition at line 88 of file SiPixelGainCalibrationForHLT.cc.

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

88  {
89  // returns vector of DetIds in map
93  DetIds_.push_back(p->detid);
94  }
95 }
#define end
Definition: vmac.h:38
Registry::const_iterator RegistryIterator
#define begin
Definition: vmac.h:31
float SiPixelGainCalibrationForHLT::getGain ( const int &  col,
const int &  row,
const Range range,
const int &  nCols,
bool &  isDeadColumn,
bool &  isNoisyColumn 
) const

Definition at line 149 of file SiPixelGainCalibrationForHLT.cc.

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

149  {
150 
151  // 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
152  unsigned int lengthOfColumnData = (range.second-range.first)/nCols;
153  unsigned int lengthOfAveragedDataInEachColumn = 2; // we always only have two values per column averaged block
154  unsigned int numberOfDataBlocksToSkip = row / numberOfRowsToAverageOver_;
155 
156  const DecodingStructure & s = (const DecodingStructure & ) *(range.first+col*lengthOfColumnData + lengthOfAveragedDataInEachColumn*numberOfDataBlocksToSkip);
157 
158  if ((s.gain & 0xFF) == deadFlag_)
159  isDeadColumn = true;
160  else if ((s.gain & 0xFF) == noisyFlag_)
161  isNoisyColumn = true;
162 
163  int maxRow = (lengthOfColumnData/lengthOfAveragedDataInEachColumn)*numberOfRowsToAverageOver_ - 1;
164  if (col >= nCols || row > maxRow){
165  throw cms::Exception("CorruptedData")
166  << "[SiPixelGainCalibrationForHLT::getGain] Pixel out of range: col " << col << " row: " << row;
167  }
168  return decodeGain(s.gain & 0xFF);
169 
170 }
float decodeGain(unsigned int gain) const
int col
Definition: cuy.py:1008
double SiPixelGainCalibrationForHLT::getGainHigh ( ) const
inline

Definition at line 66 of file SiPixelGainCalibrationForHLT.h.

References maxGain_.

double SiPixelGainCalibrationForHLT::getGainLow ( ) const
inline

Definition at line 65 of file SiPixelGainCalibrationForHLT.h.

References minGain_.

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

Definition at line 58 of file SiPixelGainCalibrationForHLT.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  {
65  return p->ncols;
66  }
67 }
Definition: DetId.h:20
Registry::const_iterator RegistryIterator
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 126 of file SiPixelGainCalibrationForHLT.cc.

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

126  {
127  // TODO MERGE THIS FUNCTION WITH GET GAIN, then provide wrappers
128 
129  // 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
130  unsigned int lengthOfColumnData = (range.second-range.first)/nCols;
131  unsigned int lengthOfAveragedDataInEachColumn = 2; // we always only have two values per column averaged block
132  unsigned int numberOfDataBlocksToSkip = row / numberOfRowsToAverageOver_;
133 
134  const DecodingStructure & s = (const DecodingStructure & ) *(range.first+col*lengthOfColumnData + lengthOfAveragedDataInEachColumn*numberOfDataBlocksToSkip);
135 
136  if ((s.ped & 0xFF) == deadFlag_)
137  isDeadColumn = true;
138  else if ((s.ped & 0xFF) == noisyFlag_)
139  isNoisyColumn = true;
140 
141  int maxRow = (lengthOfColumnData/lengthOfAveragedDataInEachColumn)*numberOfRowsToAverageOver_ - 1;
142  if (col >= nCols || row > maxRow){
143  throw cms::Exception("CorruptedData")
144  << "[SiPixelGainCalibrationForHLT::getPed] Pixel out of range: col " << col << " row: " << row;
145  }
146  return decodePed(s.ped & 0xFF);
147 }
float decodePed(unsigned int ped) const
int col
Definition: cuy.py:1008
double SiPixelGainCalibrationForHLT::getPedHigh ( ) const
inline

Definition at line 68 of file SiPixelGainCalibrationForHLT.h.

References maxPed_.

double SiPixelGainCalibrationForHLT::getPedLow ( ) const
inline

Definition at line 67 of file SiPixelGainCalibrationForHLT.h.

References minPed_.

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

Definition at line 69 of file SiPixelGainCalibrationForHLT.cc.

References indexes, AlCaHLTBitMon_ParallelJobs::p, and v_pedestals.

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

Definition at line 80 of file SiPixelGainCalibrationForHLT.cc.

References indexes, AlCaHLTBitMon_ParallelJobs::p, and v_pedestals.

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

Definition at line 39 of file SiPixelGainCalibrationForHLT.cc.

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

39  {
40  // put in SiPixelGainCalibrationForHLT of DetId
41 
42  Registry::iterator p = std::lower_bound(indexes.begin(),indexes.end(),DetId,SiPixelGainCalibrationForHLT::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.ibegin=v_pedestals.size();
50  detregistry.iend=v_pedestals.size()+sd;
51  detregistry.ncols=nCols;
52  indexes.insert(p,detregistry);
53 
54  v_pedestals.insert(v_pedestals.end(),input.first,input.second);
55  return true;
56 }
Definition: DetId.h:20
double sd
void SiPixelGainCalibrationForHLT::setData ( float  ped,
float  gain,
std::vector< char > &  vped,
bool  thisColumnIsDead = false,
bool  thisColumnIsNoisy = false 
)

Definition at line 97 of file SiPixelGainCalibrationForHLT.cc.

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

Referenced by setDeadColumn(), and setNoisyColumn().

97  {
98 
99  float theEncodedGain=0;
100  float theEncodedPed=0;
101  if(!thisColumnIsDead && !thisColumnIsNoisy){
102  theEncodedGain = encodeGain(gain);
103  theEncodedPed = encodePed (ped);
104  }
105 
106  unsigned int ped_ = (static_cast<unsigned int>(theEncodedPed)) & 0xFF;
107  unsigned int gain_ = (static_cast<unsigned int>(theEncodedGain)) & 0xFF;
108 
109  if (thisColumnIsDead)
110  {
111  ped_ = deadFlag_ & 0xFF;
112  gain_ = deadFlag_ & 0xFF;
113  }
114  else if (thisColumnIsNoisy)
115  {
116  ped_ = noisyFlag_ & 0xFF;
117  gain_ = noisyFlag_ & 0xFF;
118  }
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 }
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:82
static const char gain_[]
void SiPixelGainCalibrationForHLT::setDeadColumn ( const int &  nRows,
std::vector< char > &  vped 
)
inline

Definition at line 72 of file SiPixelGainCalibrationForHLT.h.

References setData().

72 { setData(0, 0 /*dummy values, not used*/, vped, true, false); }
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 73 of file SiPixelGainCalibrationForHLT.h.

References setData().

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

Member Data Documentation

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

Definition at line 86 of file SiPixelGainCalibrationForHLT.h.

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

float SiPixelGainCalibrationForHLT::maxGain_
private

Definition at line 87 of file SiPixelGainCalibrationForHLT.h.

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

float SiPixelGainCalibrationForHLT::maxPed_
private

Definition at line 87 of file SiPixelGainCalibrationForHLT.h.

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

float SiPixelGainCalibrationForHLT::minGain_
private

Definition at line 87 of file SiPixelGainCalibrationForHLT.h.

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

float SiPixelGainCalibrationForHLT::minPed_
private

Definition at line 87 of file SiPixelGainCalibrationForHLT.h.

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

unsigned int SiPixelGainCalibrationForHLT::nBinsToUseForEncoding_
private

Definition at line 90 of file SiPixelGainCalibrationForHLT.h.

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

unsigned int SiPixelGainCalibrationForHLT::noisyFlag_
private

Definition at line 92 of file SiPixelGainCalibrationForHLT.h.

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

unsigned int SiPixelGainCalibrationForHLT::numberOfRowsToAverageOver_
private

Definition at line 89 of file SiPixelGainCalibrationForHLT.h.

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

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

Definition at line 85 of file SiPixelGainCalibrationForHLT.h.

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