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 | Friends
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
 
float getGainHigh () const
 
float 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
 
std::pair< float, float > getPedAndGain (const int &col, const int &row, const Range &range, const int &nCols, bool &isDeadColumn, bool &isNoisyColumn) const
 
float getPedHigh () const
 
float 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 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)
 
 ~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)
 
template<class Archive >
void serialize (Archive &ar, const unsigned int version)
 

Private Attributes

unsigned int deadFlag_
 
float gainPrecision
 
std::vector< DetRegistryindexes
 
float maxGain_
 
float maxPed_
 
float minGain_
 
float minPed_
 
unsigned int nBinsToUseForEncoding_
 
unsigned int noisyFlag_
 
unsigned int numberOfRowsToAverageOver_
 
float pedPrecision
 
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 for use at HLT. Stores only average gain and average pedestal per column.

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

Definition at line 29 of file SiPixelGainCalibrationForHLT.h.

Member Typedef Documentation

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

Definition at line 52 of file SiPixelGainCalibrationForHLT.h.

Definition at line 53 of file SiPixelGainCalibrationForHLT.h.

Definition at line 54 of file SiPixelGainCalibrationForHLT.h.

typedef Registry::const_iterator SiPixelGainCalibrationForHLT::RegistryIterator

Definition at line 55 of file SiPixelGainCalibrationForHLT.h.

Constructor & Destructor Documentation

SiPixelGainCalibrationForHLT::SiPixelGainCalibrationForHLT ( )

Definition at line 9 of file SiPixelGainCalibrationForHLT.cc.

References deadFlag_, Exception, and initialize().

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

Definition at line 25 of file SiPixelGainCalibrationForHLT.cc.

References deadFlag_, Exception, and initialize().

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

Definition at line 60 of file SiPixelGainCalibrationForHLT.h.

60 {}

Member Function Documentation

float SiPixelGainCalibrationForHLT::decodeGain ( unsigned int  gain) const
inlineprivate
float SiPixelGainCalibrationForHLT::decodePed ( unsigned int  ped) const
inlineprivate
float SiPixelGainCalibrationForHLT::encodeGain ( const float &  gain)
private

Definition at line 207 of file SiPixelGainCalibrationForHLT.cc.

References Exception, maxGain_, minGain_, and nBinsToUseForEncoding_.

Referenced by setData().

207  {
208 
209  if(gain < minGain_ || gain > maxGain_ ) {
210  throw cms::Exception("InsertFailure")
211  << "[SiPixelGainCalibrationForHLT::encodeGain] Trying to encode gain (" << gain << ") out of range [" << minGain_ << "," << maxGain_ << "]\n";
212  } else {
213  float precision = (maxGain_-minGain_)/static_cast<float>(nBinsToUseForEncoding_);
214  float encodedGain = (float)((gain-minGain_)/precision);
215  return encodedGain;
216  }
217 
218 }
float SiPixelGainCalibrationForHLT::encodePed ( const float &  ped)
private

Definition at line 220 of file SiPixelGainCalibrationForHLT.cc.

References Exception, maxPed_, minPed_, and nBinsToUseForEncoding_.

Referenced by setData().

220  {
221 
222  if(ped < minPed_ || ped > maxPed_ ) {
223  throw cms::Exception("InsertFailure")
224  << "[SiPixelGainCalibrationForHLT::encodePed] Trying to encode pedestal (" << ped << ") out of range [" << minPed_ << "," << maxPed_ << "]\n";
225  } else {
226  float precision = (maxPed_-minPed_)/static_cast<float>(nBinsToUseForEncoding_);
227  float encodedPed = (float)((ped-minPed_)/precision);
228  return encodedPed;
229  }
230 
231 }
void SiPixelGainCalibrationForHLT::getDetIds ( std::vector< uint32_t > &  DetIds_) const

Definition at line 97 of file SiPixelGainCalibrationForHLT.cc.

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

97  {
98  // returns vector of DetIds in map
102  DetIds_.push_back(p->detid);
103  }
104 }
#define end
Definition: vmac.h:37
Registry::const_iterator RegistryIterator
#define begin
Definition: vmac.h:30
float SiPixelGainCalibrationForHLT::getGain ( const int &  col,
const int &  row,
const Range range,
const int &  nCols,
bool &  isDeadColumn,
bool &  isNoisyColumn 
) const

Definition at line 184 of file SiPixelGainCalibrationForHLT.cc.

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

184  {
185 
186  // 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
187  unsigned int lengthOfColumnData = (range.second-range.first)/nCols;
188  unsigned int lengthOfAveragedDataInEachColumn = 2; // we always only have two values per column averaged block
189  unsigned int numberOfDataBlocksToSkip = row / numberOfRowsToAverageOver_;
190 
191  const DecodingStructure & s = (const DecodingStructure & ) *(range.first+col*lengthOfColumnData + lengthOfAveragedDataInEachColumn*numberOfDataBlocksToSkip);
192 
193  if ((s.gain & 0xFF) == deadFlag_)
194  isDeadColumn = true;
195  else if ((s.gain & 0xFF) == noisyFlag_)
196  isNoisyColumn = true;
197 
198  int maxRow = (lengthOfColumnData/lengthOfAveragedDataInEachColumn)*numberOfRowsToAverageOver_ - 1;
199  if (col >= nCols || row > maxRow){
200  throw cms::Exception("CorruptedData")
201  << "[SiPixelGainCalibrationForHLT::getGain] Pixel out of range: col " << col << " row: " << row;
202  }
203  return decodeGain(s.gain & 0xFF);
204 
205 }
float decodeGain(unsigned int gain) const
int col
Definition: cuy.py:1008
float SiPixelGainCalibrationForHLT::getGainHigh ( ) const
inline

Definition at line 72 of file SiPixelGainCalibrationForHLT.h.

References maxGain_.

float SiPixelGainCalibrationForHLT::getGainLow ( ) const
inline

Definition at line 71 of file SiPixelGainCalibrationForHLT.h.

References minGain_.

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

Definition at line 67 of file SiPixelGainCalibrationForHLT.cc.

References indexes, and AlCaHLTBitMon_ParallelJobs::p.

67  {
68  // get number of columns of DetId
70  if (p==indexes.end()|| p->detid!=DetId)
71  return 0;
72  else
73  {
74  return p->ncols;
75  }
76 }
Definition: DetId.h:18
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 161 of file SiPixelGainCalibrationForHLT.cc.

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

161  {
162  // TODO MERGE THIS FUNCTION WITH GET GAIN, then provide wrappers ( VI done, see above)
163 
164  // 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
165  unsigned int lengthOfColumnData = (range.second-range.first)/nCols;
166  unsigned int lengthOfAveragedDataInEachColumn = 2; // we always only have two values per column averaged block
167  unsigned int numberOfDataBlocksToSkip = row / numberOfRowsToAverageOver_;
168 
169  const DecodingStructure & s = (const DecodingStructure & ) *(range.first+col*lengthOfColumnData + lengthOfAveragedDataInEachColumn*numberOfDataBlocksToSkip);
170 
171  if ((s.ped & 0xFF) == deadFlag_)
172  isDeadColumn = true;
173  else if ((s.ped & 0xFF) == noisyFlag_)
174  isNoisyColumn = true;
175 
176  int maxRow = (lengthOfColumnData/lengthOfAveragedDataInEachColumn)*numberOfRowsToAverageOver_ - 1;
177  if (col >= nCols || row > maxRow){
178  throw cms::Exception("CorruptedData")
179  << "[SiPixelGainCalibrationForHLT::getPed] Pixel out of range: col " << col << " row: " << row;
180  }
181  return decodePed(s.ped & 0xFF);
182 }
float decodePed(unsigned int ped) const
int col
Definition: cuy.py:1008
std::pair< float, float > SiPixelGainCalibrationForHLT::getPedAndGain ( const int &  col,
const int &  row,
const Range range,
const int &  nCols,
bool &  isDeadColumn,
bool &  isNoisyColumn 
) const

Definition at line 136 of file SiPixelGainCalibrationForHLT.cc.

References deadFlag_, decodeGain(), decodePed(), SiPixelGainCalibrationForHLT::DecodingStructure::gain, noisyFlag_, numberOfRowsToAverageOver_, SiPixelGainCalibrationForHLT::DecodingStructure::ped, and alignCSCRings::s.

136  {
137  // 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
138  unsigned int lengthOfColumnData = (range.second-range.first)/nCols;
139  unsigned int lengthOfAveragedDataInEachColumn = 2; // we always only have two values per column averaged block
140  unsigned int numberOfDataBlocksToSkip = row / numberOfRowsToAverageOver_;
141 
142  const DecodingStructure & s = (const DecodingStructure & ) *(range.first + col*lengthOfColumnData + lengthOfAveragedDataInEachColumn*numberOfDataBlocksToSkip);
143 
144  isDeadColumn = (s.ped & 0xFF) == deadFlag_;
145  isNoisyColumn = (s.ped & 0xFF) == noisyFlag_;
146 
147  /*
148  int maxRow = (lengthOfColumnData/lengthOfAveragedDataInEachColumn)*numberOfRowsToAverageOver_ - 1;
149  if (col >= nCols || row > maxRow){
150  throw cms::Exception("CorruptedData")
151  << "[SiPixelGainCalibrationForHLT::getPed] Pixel out of range: col " << col << " row: " << row;
152  }
153  */
154 
155  return std::make_pair(decodePed(s.ped & 0xFF),decodeGain(s.gain & 0xFF));
156 
157 
158 }
float decodePed(unsigned int ped) const
float decodeGain(unsigned int gain) const
int col
Definition: cuy.py:1008
float SiPixelGainCalibrationForHLT::getPedHigh ( ) const
inline

Definition at line 74 of file SiPixelGainCalibrationForHLT.h.

References maxPed_.

float SiPixelGainCalibrationForHLT::getPedLow ( ) const
inline

Definition at line 73 of file SiPixelGainCalibrationForHLT.h.

References minPed_.

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

Definition at line 78 of file SiPixelGainCalibrationForHLT.cc.

References indexes, AlCaHLTBitMon_ParallelJobs::p, and v_pedestals.

78  {
79  // get SiPixelGainCalibrationForHLT Range of DetId
80 
82  if (p==indexes.end()|| p->detid!=DetId)
84  else
85  return SiPixelGainCalibrationForHLT::Range(v_pedestals.begin()+p->ibegin,v_pedestals.begin()+p->iend);
86 }
std::pair< ContainerIterator, ContainerIterator > Range
Definition: DetId.h:18
Registry::const_iterator RegistryIterator
const std::pair< const SiPixelGainCalibrationForHLT::Range, const int > SiPixelGainCalibrationForHLT::getRangeAndNCols ( const uint32_t &  detID) const

Definition at line 89 of file SiPixelGainCalibrationForHLT.cc.

References indexes, AlCaHLTBitMon_ParallelJobs::p, and v_pedestals.

89  {
91  if (p==indexes.end()|| p->detid!=DetId)
92  return std::make_pair(SiPixelGainCalibrationForHLT::Range(v_pedestals.end(),v_pedestals.end()), 0);
93  else
94  return std::make_pair(SiPixelGainCalibrationForHLT::Range(v_pedestals.begin()+p->ibegin,v_pedestals.begin()+p->iend), p->ncols);
95 }
std::pair< ContainerIterator, ContainerIterator > Range
Definition: DetId.h:18
Registry::const_iterator RegistryIterator
void SiPixelGainCalibrationForHLT::initialize ( )
bool SiPixelGainCalibrationForHLT::put ( const uint32_t &  detID,
Range  input,
const int &  nCols 
)

Definition at line 48 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.

48  {
49  // put in SiPixelGainCalibrationForHLT of DetId
50 
51  Registry::iterator p = std::lower_bound(indexes.begin(),indexes.end(),DetId,SiPixelGainCalibrationForHLT::StrictWeakOrdering());
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.ibegin=v_pedestals.size();
59  detregistry.iend=v_pedestals.size()+sd;
60  detregistry.ncols=nCols;
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:43
Definition: DetId.h:18
double sd
template<class Archive >
void SiPixelGainCalibrationForHLT::serialize ( Archive &  ar,
const unsigned int  version 
)
private
void SiPixelGainCalibrationForHLT::setData ( float  ped,
float  gain,
std::vector< char > &  vped,
bool  thisColumnIsDead = false,
bool  thisColumnIsNoisy = false 
)

Definition at line 106 of file SiPixelGainCalibrationForHLT.cc.

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

Referenced by setDeadColumn(), and setNoisyColumn().

106  {
107 
108  float theEncodedGain=0;
109  float theEncodedPed=0;
110  if(!thisColumnIsDead && !thisColumnIsNoisy){
111  theEncodedGain = encodeGain(gain);
112  theEncodedPed = encodePed (ped);
113  }
114 
115  unsigned int ped_ = (static_cast<unsigned int>(theEncodedPed)) & 0xFF;
116  unsigned int gain_ = (static_cast<unsigned int>(theEncodedGain)) & 0xFF;
117 
118  if (thisColumnIsDead)
119  {
120  ped_ = deadFlag_ & 0xFF;
121  gain_ = deadFlag_ & 0xFF;
122  }
123  else if (thisColumnIsNoisy)
124  {
125  ped_ = noisyFlag_ & 0xFF;
126  gain_ = noisyFlag_ & 0xFF;
127  }
128 
129  unsigned int data = (ped_ << 8) | gain_ ;
130  vped.resize(vped.size()+2);
131  // insert in vector of char
132  ::memcpy((void*)(&vped[vped.size()-2]),(void*)(&data),2);
133 }
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 78 of file SiPixelGainCalibrationForHLT.h.

References setData().

78 { 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 79 of file SiPixelGainCalibrationForHLT.h.

References setData().

79 { 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)

Friends And Related Function Documentation

friend class boost::serialization::access
friend

Definition at line 105 of file SiPixelGainCalibrationForHLT.h.

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

Definition at line 105 of file SiPixelGainCalibrationForHLT.h.

Member Data Documentation

unsigned int SiPixelGainCalibrationForHLT::deadFlag_
private
float SiPixelGainCalibrationForHLT::gainPrecision
private

Definition at line 98 of file SiPixelGainCalibrationForHLT.h.

Referenced by decodeGain(), and initialize().

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

Definition at line 95 of file SiPixelGainCalibrationForHLT.h.

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

float SiPixelGainCalibrationForHLT::maxGain_
private

Definition at line 96 of file SiPixelGainCalibrationForHLT.h.

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

float SiPixelGainCalibrationForHLT::maxPed_
private

Definition at line 96 of file SiPixelGainCalibrationForHLT.h.

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

float SiPixelGainCalibrationForHLT::minGain_
private

Definition at line 96 of file SiPixelGainCalibrationForHLT.h.

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

float SiPixelGainCalibrationForHLT::minPed_
private

Definition at line 96 of file SiPixelGainCalibrationForHLT.h.

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

unsigned int SiPixelGainCalibrationForHLT::nBinsToUseForEncoding_
private

Definition at line 101 of file SiPixelGainCalibrationForHLT.h.

Referenced by encodeGain(), encodePed(), and initialize().

unsigned int SiPixelGainCalibrationForHLT::noisyFlag_
private

Definition at line 103 of file SiPixelGainCalibrationForHLT.h.

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

unsigned int SiPixelGainCalibrationForHLT::numberOfRowsToAverageOver_
private
float SiPixelGainCalibrationForHLT::pedPrecision
private

Definition at line 98 of file SiPixelGainCalibrationForHLT.h.

Referenced by decodePed(), and initialize().

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

Definition at line 94 of file SiPixelGainCalibrationForHLT.h.

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