CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
List of all members | Public Member Functions | Public Attributes
SiPixelRecHitQuality::Packing Class Reference

#include <SiPixelRecHitQuality.h>

Public Member Functions

bool hasBadPixels (QualWordType qualWord) const
 
bool hasFilledProb (QualWordType qualWord) const
 
bool isOnEdge (QualWordType qualWord) const
 
 Packing ()
 
float probabilityQ (QualWordType qualWord) const
 
float probabilityX (QualWordType qualWord) const
 
float probabilityXY (QualWordType qualWord) const
 
float probabilityY (QualWordType qualWord) const
 
int qBin (QualWordType qualWord) const
 
void setHasBadPixels (bool flag, QualWordType &qualWord) const
 
void setHasFilledProb (bool flag, QualWordType &qualWord) const
 
void setIsOnEdge (bool flag, QualWordType &qualWord) const
 
void setProbabilityQ (float prob, QualWordType &qualWord) const
 
void setProbabilityXY (float prob, QualWordType &qualWord) const
 
void setQBin (int qbin, QualWordType &qualWord) const
 
void setSpansTwoROCs (bool flag, QualWordType &qualWord) const
 
bool spansTwoROCs (QualWordType qualWord) const
 

Public Attributes

QualWordType bad_mask
 
int bad_shift
 
char bad_width
 
QualWordType edge_mask
 
int edge_shift
 
char edge_width
 
QualWordType hasFilledProb_mask
 
int hasFilledProb_shift
 
char hasFilledProb_width
 
double probX_1_over_log_units
 
QualWordType probX_mask
 
int probX_shift
 
float probX_units
 
char probX_width
 
double probY_1_over_log_units
 
QualWordType probY_mask
 
int probY_shift
 
float probY_units
 
char probY_width
 
QualWordType qBin_mask
 
int qBin_shift
 
char qBin_width
 
char spare_width
 
QualWordType twoROC_mask
 
int twoROC_shift
 
char twoROC_width
 

Detailed Description

Definition at line 11 of file SiPixelRecHitQuality.h.

Constructor & Destructor Documentation

SiPixelRecHitQuality::Packing::Packing ( )

Definition at line 5 of file SiPixelRecHitQuality.cc.

References bad_mask, bad_shift, bad_width, edge_mask, edge_shift, edge_width, Exception, hasFilledProb_mask, hasFilledProb_shift, hasFilledProb_width, log, probX_1_over_log_units, probX_mask, probX_shift, probX_units, probX_width, probY_1_over_log_units, probY_mask, probY_shift, probY_units, probY_width, qBin_mask, qBin_shift, qBin_width, spare_width, twoROC_mask, twoROC_shift, and twoROC_width.

5  {
6  // Constructor: pre-computes masks and shifts from field widths
7  // X is now XY
8  // Y is now Q
9  probX_width = 14;
10  probY_width = 8;
11  qBin_width = 3;
12  edge_width = 1;
13  bad_width = 1;
14  twoROC_width = 1;
16  spare_width = 3;
17 
19  spare_width !=
20  32) {
21  throw cms::Exception("SiPixelRecHitQuality::Packing: ")
22  << "\nERROR: The allocated bits for the quality word to not sum to 32."
23  << "\n\n";
24  }
25 
26  probX_units = 1.0018;
27  probY_units = 1.0461;
30 
31  // Fields are counted from right to left!
32  probX_shift = 0;
39 
40  // Ensure the complement of the correct
41  // number of bits:
42  QualWordType zero32 = 0; // 32-bit wide set of 0's
43 
44  probX_mask = ~(~zero32 << probX_width);
45  probY_mask = ~(~zero32 << probY_width);
46  qBin_mask = ~(~zero32 << qBin_width);
47  edge_mask = ~(~zero32 << edge_width);
48  bad_mask = ~(~zero32 << bad_width);
49  twoROC_mask = ~(~zero32 << twoROC_width);
51 }
static std::vector< std::string > checklist log

Member Function Documentation

bool SiPixelRecHitQuality::Packing::hasBadPixels ( QualWordType  qualWord) const
inline

Definition at line 99 of file SiPixelRecHitQuality.h.

References bad_mask, and bad_shift.

Referenced by SiPixelRecHit::hasBadPixels().

bool SiPixelRecHitQuality::Packing::hasFilledProb ( QualWordType  qualWord) const
inline

Definition at line 103 of file SiPixelRecHitQuality.h.

References hasFilledProb_mask, and hasFilledProb_shift.

Referenced by SiPixelRecHit::hasFilledProb().

103  {
104  return (qualWord >> hasFilledProb_shift) & hasFilledProb_mask;
105  }
bool SiPixelRecHitQuality::Packing::isOnEdge ( QualWordType  qualWord) const
inline

Definition at line 97 of file SiPixelRecHitQuality.h.

References edge_mask, and edge_shift.

Referenced by SiPixelRecHit::isOnEdge().

float SiPixelRecHitQuality::Packing::probabilityQ ( QualWordType  qualWord) const
inline

Definition at line 75 of file SiPixelRecHitQuality.h.

References funct::pow(), probY_mask, probY_shift, probY_units, and SiPixelRecHitQuality::warningOutOfBoundRaw().

Referenced by SiPixelRecHit::probabilityQ().

75  {
76  int raw = (qualWord >> probY_shift) & probY_mask;
77  if (raw < 0 || raw > 255) {
78  warningOutOfBoundRaw("Q", raw, qualWord);
79  raw = 255;
80  }
81  float prob = (raw == 255) ? 0 : pow(probY_units, (float)(-raw));
82  // cout << "Bits = " << raw << " --> Prob = " << prob << endl;
83  return prob;
84  }
static void warningOutOfBoundRaw(const char *iVariable, int iRaw, QualWordType const &)
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:29
float SiPixelRecHitQuality::Packing::probabilityX ( QualWordType  qualWord) const
inline

Definition at line 56 of file SiPixelRecHitQuality.h.

References SiPixelRecHitQuality::warningObsolete().

Referenced by SiPixelRecHit::probabilityX().

56  {
58  return -10;
59  }
float SiPixelRecHitQuality::Packing::probabilityXY ( QualWordType  qualWord) const
inline

Definition at line 65 of file SiPixelRecHitQuality.h.

References funct::pow(), probX_mask, probX_shift, probX_units, and SiPixelRecHitQuality::warningOutOfBoundRaw().

Referenced by SiPixelRecHit::probabilityXY().

65  {
66  int raw = (qualWord >> probX_shift) & probX_mask;
67  if (raw < 0 || raw > 16383) {
68  warningOutOfBoundRaw("XY", raw, qualWord);
69  raw = 16383;
70  }
71  float prob = (raw == 16383) ? 0 : pow(probX_units, (float)(-raw));
72  // cout << "Bits = " << raw << " --> Prob = " << prob << endl;
73  return prob;
74  }
static void warningOutOfBoundRaw(const char *iVariable, int iRaw, QualWordType const &)
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:29
float SiPixelRecHitQuality::Packing::probabilityY ( QualWordType  qualWord) const
inline

Definition at line 60 of file SiPixelRecHitQuality.h.

References SiPixelRecHitQuality::warningObsolete().

Referenced by SiPixelRecHit::probabilityY().

60  {
62  return -10;
63  }
int SiPixelRecHitQuality::Packing::qBin ( QualWordType  qualWord) const
inline

Definition at line 87 of file SiPixelRecHitQuality.h.

References qBin_mask, qBin_shift, and SiPixelRecHitQuality::warningOutOfBoundQbin().

Referenced by SiPixelRecHit::qBin().

87  {
88  int qbin = (qualWord >> qBin_shift) & qBin_mask;
89  if (qbin < 0 || qbin > 7) {
90  warningOutOfBoundQbin(qbin, qualWord);
91  qbin = 0;
92  }
93  return qbin;
94  }
static void warningOutOfBoundQbin(int, QualWordType const &)
void SiPixelRecHitQuality::Packing::setHasBadPixels ( bool  flag,
QualWordType qualWord 
) const
inline

Definition at line 145 of file SiPixelRecHitQuality.h.

References bad_mask, and bad_shift.

Referenced by PixelCPEBase::rawQualityWord().

145  {
146  qualWord |= ((flag & bad_mask) << bad_shift);
147  }
void SiPixelRecHitQuality::Packing::setHasFilledProb ( bool  flag,
QualWordType qualWord 
) const
inline

Definition at line 151 of file SiPixelRecHitQuality.h.

References hasFilledProb_mask, and hasFilledProb_shift.

Referenced by PixelCPEBase::rawQualityWord().

151  {
152  qualWord |= ((flag & hasFilledProb_mask) << hasFilledProb_shift);
153  }
void SiPixelRecHitQuality::Packing::setIsOnEdge ( bool  flag,
QualWordType qualWord 
) const
inline

Definition at line 144 of file SiPixelRecHitQuality.h.

References edge_mask, and edge_shift.

Referenced by PixelCPEBase::rawQualityWord().

144 { qualWord |= ((flag & edge_mask) << edge_shift); }
void SiPixelRecHitQuality::Packing::setProbabilityQ ( float  prob,
QualWordType qualWord 
) const
inline

Definition at line 123 of file SiPixelRecHitQuality.h.

References ntuplePlotting::draw(), geometryDiff::epsilon, validate-o2o-wbm::f, log, probY_1_over_log_units, probY_mask, probY_shift, and SiPixelRecHitQuality::warningOutOfBoundProb().

Referenced by PixelCPEBase::rawQualityWord().

123  {
124  if (prob > 1.0f && prob <= 1.0f + std::numeric_limits<float>::epsilon()) {
125  prob = 1;
126  } else if (prob < 0.0f || prob > 1.0f + std::numeric_limits<float>::epsilon()) {
127  warningOutOfBoundProb("Q", prob, qualWord);
128  prob = 0;
129  }
130  double draw = (prob <= 1E-5) ? 255 : -log((double)prob) * probY_1_over_log_units;
131  unsigned int raw = (int)(draw + 0.5); // convert to integer, round correctly
132  // cout << "Prob = " << prob << " --> Bits = " << raw << endl;
133  qualWord |= ((raw & probY_mask) << probY_shift);
134  }
static std::vector< std::string > checklist log
static void warningOutOfBoundProb(const char *iVariable, float, QualWordType const &)
void SiPixelRecHitQuality::Packing::setProbabilityXY ( float  prob,
QualWordType qualWord 
) const
inline

Definition at line 111 of file SiPixelRecHitQuality.h.

References ntuplePlotting::draw(), geometryDiff::epsilon, validate-o2o-wbm::f, log, probX_1_over_log_units, probX_mask, probX_shift, and SiPixelRecHitQuality::warningOutOfBoundProb().

Referenced by PixelCPEBase::rawQualityWord().

111  {
112  if (prob > 1.0f && prob <= 1.0f + std::numeric_limits<float>::epsilon()) {
113  prob = 1;
114  } else if (prob < 0.0f || prob > 1.0f + std::numeric_limits<float>::epsilon()) {
115  warningOutOfBoundProb("XY", prob, qualWord);
116  prob = 0;
117  }
118  double draw = (prob <= 1.6E-13) ? 16383 : -log((double)prob) * probX_1_over_log_units;
119  unsigned int raw = (int)(draw + 0.5); // convert to integer, round correctly
120  // cout << "Prob = " << prob << " --> Bits = " << raw << endl;
121  qualWord |= ((raw & probX_mask) << probX_shift);
122  }
static std::vector< std::string > checklist log
static void warningOutOfBoundProb(const char *iVariable, float, QualWordType const &)
void SiPixelRecHitQuality::Packing::setQBin ( int  qbin,
QualWordType qualWord 
) const
inline

Definition at line 136 of file SiPixelRecHitQuality.h.

References qBin_mask, qBin_shift, and SiPixelRecHitQuality::warningOutOfBoundQbin().

Referenced by PixelCPEBase::rawQualityWord().

136  {
137  if (qbin < 0 || qbin > 7) {
138  warningOutOfBoundQbin(qbin, qualWord);
139  qbin = 0;
140  }
141  qualWord |= ((qbin & qBin_mask) << qBin_shift);
142  }
static void warningOutOfBoundQbin(int, QualWordType const &)
void SiPixelRecHitQuality::Packing::setSpansTwoROCs ( bool  flag,
QualWordType qualWord 
) const
inline

Definition at line 148 of file SiPixelRecHitQuality.h.

References twoROC_mask, and twoROC_shift.

Referenced by PixelCPEBase::rawQualityWord().

148  {
149  qualWord |= ((flag & twoROC_mask) << twoROC_shift);
150  }
bool SiPixelRecHitQuality::Packing::spansTwoROCs ( QualWordType  qualWord) const
inline

Definition at line 101 of file SiPixelRecHitQuality.h.

References twoROC_mask, and twoROC_shift.

Referenced by SiPixelRecHit::spansTwoROCs().

Member Data Documentation

QualWordType SiPixelRecHitQuality::Packing::bad_mask

Definition at line 37 of file SiPixelRecHitQuality.h.

Referenced by hasBadPixels(), Packing(), and setHasBadPixels().

int SiPixelRecHitQuality::Packing::bad_shift

Definition at line 38 of file SiPixelRecHitQuality.h.

Referenced by hasBadPixels(), Packing(), and setHasBadPixels().

char SiPixelRecHitQuality::Packing::bad_width

Definition at line 39 of file SiPixelRecHitQuality.h.

Referenced by Packing().

QualWordType SiPixelRecHitQuality::Packing::edge_mask

Definition at line 33 of file SiPixelRecHitQuality.h.

Referenced by isOnEdge(), Packing(), and setIsOnEdge().

int SiPixelRecHitQuality::Packing::edge_shift

Definition at line 34 of file SiPixelRecHitQuality.h.

Referenced by isOnEdge(), Packing(), and setIsOnEdge().

char SiPixelRecHitQuality::Packing::edge_width

Definition at line 35 of file SiPixelRecHitQuality.h.

Referenced by Packing().

QualWordType SiPixelRecHitQuality::Packing::hasFilledProb_mask

Definition at line 45 of file SiPixelRecHitQuality.h.

Referenced by hasFilledProb(), Packing(), and setHasFilledProb().

int SiPixelRecHitQuality::Packing::hasFilledProb_shift

Definition at line 46 of file SiPixelRecHitQuality.h.

Referenced by hasFilledProb(), Packing(), and setHasFilledProb().

char SiPixelRecHitQuality::Packing::hasFilledProb_width

Definition at line 47 of file SiPixelRecHitQuality.h.

Referenced by Packing().

double SiPixelRecHitQuality::Packing::probX_1_over_log_units

Definition at line 20 of file SiPixelRecHitQuality.h.

Referenced by Packing(), and setProbabilityXY().

QualWordType SiPixelRecHitQuality::Packing::probX_mask

Definition at line 17 of file SiPixelRecHitQuality.h.

Referenced by Packing(), probabilityXY(), and setProbabilityXY().

int SiPixelRecHitQuality::Packing::probX_shift

Definition at line 18 of file SiPixelRecHitQuality.h.

Referenced by Packing(), probabilityXY(), and setProbabilityXY().

float SiPixelRecHitQuality::Packing::probX_units

Definition at line 19 of file SiPixelRecHitQuality.h.

Referenced by Packing(), and probabilityXY().

char SiPixelRecHitQuality::Packing::probX_width

Definition at line 21 of file SiPixelRecHitQuality.h.

Referenced by Packing().

double SiPixelRecHitQuality::Packing::probY_1_over_log_units

Definition at line 26 of file SiPixelRecHitQuality.h.

Referenced by Packing(), and setProbabilityQ().

QualWordType SiPixelRecHitQuality::Packing::probY_mask

Definition at line 23 of file SiPixelRecHitQuality.h.

Referenced by Packing(), probabilityQ(), and setProbabilityQ().

int SiPixelRecHitQuality::Packing::probY_shift

Definition at line 24 of file SiPixelRecHitQuality.h.

Referenced by Packing(), probabilityQ(), and setProbabilityQ().

float SiPixelRecHitQuality::Packing::probY_units

Definition at line 25 of file SiPixelRecHitQuality.h.

Referenced by Packing(), and probabilityQ().

char SiPixelRecHitQuality::Packing::probY_width

Definition at line 27 of file SiPixelRecHitQuality.h.

Referenced by Packing().

QualWordType SiPixelRecHitQuality::Packing::qBin_mask

Definition at line 29 of file SiPixelRecHitQuality.h.

Referenced by Packing(), qBin(), and setQBin().

int SiPixelRecHitQuality::Packing::qBin_shift

Definition at line 30 of file SiPixelRecHitQuality.h.

Referenced by Packing(), qBin(), and setQBin().

char SiPixelRecHitQuality::Packing::qBin_width

Definition at line 31 of file SiPixelRecHitQuality.h.

Referenced by Packing().

char SiPixelRecHitQuality::Packing::spare_width

Definition at line 49 of file SiPixelRecHitQuality.h.

Referenced by Packing().

QualWordType SiPixelRecHitQuality::Packing::twoROC_mask

Definition at line 41 of file SiPixelRecHitQuality.h.

Referenced by Packing(), setSpansTwoROCs(), and spansTwoROCs().

int SiPixelRecHitQuality::Packing::twoROC_shift

Definition at line 42 of file SiPixelRecHitQuality.h.

Referenced by Packing(), setSpansTwoROCs(), and spansTwoROCs().

char SiPixelRecHitQuality::Packing::twoROC_width

Definition at line 43 of file SiPixelRecHitQuality.h.

Referenced by Packing().