CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros 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)
 
void setHasFilledProb (bool flag, QualWordType &qualWord)
 
void setIsOnEdge (bool flag, QualWordType &qualWord)
 
void setProbabilityQ (float prob, QualWordType &qualWord)
 
void setProbabilityXY (float prob, QualWordType &qualWord)
 
void setQBin (int qbin, QualWordType &qualWord)
 
void setSpansTwoROCs (bool flag, QualWordType &qualWord)
 
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 23 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, edm::hlt::Exception, hasFilledProb_mask, hasFilledProb_shift, hasFilledProb_width, create_public_lumi_plots::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.

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

Member Function Documentation

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

Definition at line 114 of file SiPixelRecHitQuality.h.

References bad_mask, and bad_shift.

Referenced by GCC11_FINAL::hasBadPixels().

114  {
115  return (qualWord >> bad_shift) & bad_mask;
116  }
bool SiPixelRecHitQuality::Packing::hasFilledProb ( QualWordType  qualWord) const
inline

Definition at line 122 of file SiPixelRecHitQuality.h.

References hasFilledProb_mask, and hasFilledProb_shift.

Referenced by GCC11_FINAL::hasFilledProb().

122  {
123  return (qualWord >> hasFilledProb_shift) & hasFilledProb_mask;
124  }
bool SiPixelRecHitQuality::Packing::isOnEdge ( QualWordType  qualWord) const
inline

Definition at line 110 of file SiPixelRecHitQuality.h.

References edge_mask, and edge_shift.

Referenced by GCC11_FINAL::isOnEdge().

110  {
111  return (qualWord >> edge_shift) & edge_mask;
112  }
float SiPixelRecHitQuality::Packing::probabilityQ ( QualWordType  qualWord) const
inline

Definition at line 88 of file SiPixelRecHitQuality.h.

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

Referenced by GCC11_FINAL::probabilityQ().

88  {
89  int raw = (qualWord >> probY_shift) & probY_mask;
90  if(raw<0 || raw >255) {
91  edm::LogWarning("OutOfBounds") << "Probability Q outside the bounds of the quality word. Defaulting to Prob=0. Raw = " << raw << " QualityWord = " << qualWord;
92  raw = 255;
93  }
94  float prob = (raw==255) ? 0 : pow( probY_units, (float)( -raw) );
95  // cout << "Bits = " << raw << " --> Prob = " << prob << endl;
96  return prob;
97  }
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:40
float SiPixelRecHitQuality::Packing::probabilityX ( QualWordType  qualWord) const
inline

Definition at line 69 of file SiPixelRecHitQuality.h.

Referenced by GCC11_FINAL::probabilityX().

69  {
70  edm::LogWarning("ObsoleteVariable") << "Since 39x, probabilityX and probabilityY have been replaced by probabilityXY and probabilityQ";
71  return -10;
72  }
float SiPixelRecHitQuality::Packing::probabilityXY ( QualWordType  qualWord) const
inline

Definition at line 78 of file SiPixelRecHitQuality.h.

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

Referenced by GCC11_FINAL::probabilityXY().

78  {
79  int raw = (qualWord >> probX_shift) & probX_mask;
80  if(raw<0 || raw >16383) {
81  edm::LogWarning("OutOfBounds") << "Probability XY outside the bounds of the quality word. Defaulting to Prob=0. Raw = " << raw << " QualityWord = " << qualWord;
82  raw = 16383;
83  }
84  float prob = (raw==16383) ? 0: pow( probX_units, (float)( -raw) );
85  // cout << "Bits = " << raw << " --> Prob = " << prob << endl;
86  return prob;
87  }
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:40
float SiPixelRecHitQuality::Packing::probabilityY ( QualWordType  qualWord) const
inline

Definition at line 73 of file SiPixelRecHitQuality.h.

Referenced by GCC11_FINAL::probabilityY().

73  {
74  edm::LogWarning("ObsoleteVariable") << "Since 39x, probabilityX and probabilityY have been replaced by probabilityXY and probabilityQ";
75  return -10;
76  }
int SiPixelRecHitQuality::Packing::qBin ( QualWordType  qualWord) const
inline

Definition at line 100 of file SiPixelRecHitQuality.h.

References qBin_mask, and qBin_shift.

Referenced by GCC11_FINAL::qBin().

100  {
101  int qbin = (qualWord >> qBin_shift) & qBin_mask;
102  if(qbin<0 || qbin >7) {
103  edm::LogWarning("OutOfBounds") << "Qbin outside the bounds of the quality word. Defaulting to Qbin=0. Qbin = " << qbin << " QualityWord = " << qualWord;
104  qbin=0;
105  }
106  return qbin;
107  }
void SiPixelRecHitQuality::Packing::setHasBadPixels ( bool  flag,
QualWordType qualWord 
)
inline

Definition at line 163 of file SiPixelRecHitQuality.h.

References bad_mask, and bad_shift.

Referenced by PixelCPEBase::rawQualityWord(), and GCC11_FINAL::setHasBadPixels().

163  {
164  qualWord |= ((flag & bad_mask) << bad_shift);
165  }
long int flag
Definition: mlp_lapack.h:47
void SiPixelRecHitQuality::Packing::setHasFilledProb ( bool  flag,
QualWordType qualWord 
)
inline

Definition at line 169 of file SiPixelRecHitQuality.h.

References hasFilledProb_mask, and hasFilledProb_shift.

Referenced by PixelCPEBase::rawQualityWord(), and GCC11_FINAL::setHasFilledProb().

169  {
170  qualWord |= ((flag & hasFilledProb_mask) << hasFilledProb_shift);
171  }
long int flag
Definition: mlp_lapack.h:47
void SiPixelRecHitQuality::Packing::setIsOnEdge ( bool  flag,
QualWordType qualWord 
)
inline

Definition at line 160 of file SiPixelRecHitQuality.h.

References edge_mask, and edge_shift.

Referenced by PixelCPEBase::rawQualityWord(), and GCC11_FINAL::setIsOnEdge().

160  {
161  qualWord |= ((flag & edge_mask) << edge_shift);
162  }
long int flag
Definition: mlp_lapack.h:47
void SiPixelRecHitQuality::Packing::setProbabilityQ ( float  prob,
QualWordType qualWord 
)
inline

Definition at line 140 of file SiPixelRecHitQuality.h.

References cond::draw(), create_public_lumi_plots::log, probY_1_over_log_units, probY_mask, and probY_shift.

Referenced by PixelCPEBase::rawQualityWord(), and GCC11_FINAL::setProbabilityQ().

140  {
141  if(prob<0 || prob>1) {
142  edm::LogWarning("OutOfBounds") << "Prob Q outside the bounds of the quality word. Defaulting to Prob=0. Prob = " << prob << " QualityWord = " << qualWord;
143  prob=0;
144  }
145  double draw = (prob<=1E-5) ? 255 : - log( (double) prob ) * probY_1_over_log_units;
146  unsigned int raw = (int) (draw+0.5); // convert to integer, round correctly
147  // cout << "Prob = " << prob << " --> Bits = " << raw << endl;
148  qualWord |= ((raw & probY_mask) << probY_shift);
149  }
void draw(std::vector< TH2F > &graphData, std::string filename)
void SiPixelRecHitQuality::Packing::setProbabilityXY ( float  prob,
QualWordType qualWord 
)
inline

Definition at line 130 of file SiPixelRecHitQuality.h.

References cond::draw(), create_public_lumi_plots::log, probX_1_over_log_units, probX_mask, and probX_shift.

Referenced by PixelCPEBase::rawQualityWord(), and GCC11_FINAL::setProbabilityXY().

130  {
131  if(prob<0 || prob>1) {
132  edm::LogWarning("OutOfBounds") << "Prob XY outside the bounds of the quality word. Defaulting to Prob=0. Prob = " << prob << " QualityWord = " << qualWord;
133  prob=0;
134  }
135  double draw = (prob<=1.6E-13) ? 16383 : - log( (double) prob ) * probX_1_over_log_units;
136  unsigned int raw = (int) (draw+0.5); // convert to integer, round correctly
137  // cout << "Prob = " << prob << " --> Bits = " << raw << endl;
138  qualWord |= ((raw & probX_mask) << probX_shift);
139  }
void draw(std::vector< TH2F > &graphData, std::string filename)
void SiPixelRecHitQuality::Packing::setQBin ( int  qbin,
QualWordType qualWord 
)
inline

Definition at line 152 of file SiPixelRecHitQuality.h.

References qBin_mask, and qBin_shift.

Referenced by PixelCPEBase::rawQualityWord(), and GCC11_FINAL::setQBin().

152  {
153  if(qbin<0 || qbin >7) {
154  edm::LogWarning("OutOfBounds") << "Qbin outside the bounds of the quality word. Defaulting to Qbin=0. Qbin = " << qbin << " QualityWord = " << qualWord;
155  qbin=0;
156  }
157  qualWord |= ((qbin & qBin_mask) << qBin_shift);
158  }
void SiPixelRecHitQuality::Packing::setSpansTwoROCs ( bool  flag,
QualWordType qualWord 
)
inline

Definition at line 166 of file SiPixelRecHitQuality.h.

References twoROC_mask, and twoROC_shift.

Referenced by PixelCPEBase::rawQualityWord(), and GCC11_FINAL::setSpansTwoROCs().

166  {
167  qualWord |= ((flag & twoROC_mask) << twoROC_shift);
168  }
long int flag
Definition: mlp_lapack.h:47
bool SiPixelRecHitQuality::Packing::spansTwoROCs ( QualWordType  qualWord) const
inline

Definition at line 118 of file SiPixelRecHitQuality.h.

References twoROC_mask, and twoROC_shift.

Referenced by GCC11_FINAL::spansTwoROCs().

118  {
119  return (qualWord >> twoROC_shift) & twoROC_mask;
120  }

Member Data Documentation

QualWordType SiPixelRecHitQuality::Packing::bad_mask

Definition at line 50 of file SiPixelRecHitQuality.h.

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

int SiPixelRecHitQuality::Packing::bad_shift

Definition at line 51 of file SiPixelRecHitQuality.h.

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

char SiPixelRecHitQuality::Packing::bad_width

Definition at line 52 of file SiPixelRecHitQuality.h.

Referenced by Packing().

QualWordType SiPixelRecHitQuality::Packing::edge_mask

Definition at line 46 of file SiPixelRecHitQuality.h.

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

int SiPixelRecHitQuality::Packing::edge_shift

Definition at line 47 of file SiPixelRecHitQuality.h.

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

char SiPixelRecHitQuality::Packing::edge_width

Definition at line 48 of file SiPixelRecHitQuality.h.

Referenced by Packing().

QualWordType SiPixelRecHitQuality::Packing::hasFilledProb_mask

Definition at line 58 of file SiPixelRecHitQuality.h.

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

int SiPixelRecHitQuality::Packing::hasFilledProb_shift

Definition at line 59 of file SiPixelRecHitQuality.h.

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

char SiPixelRecHitQuality::Packing::hasFilledProb_width

Definition at line 60 of file SiPixelRecHitQuality.h.

Referenced by Packing().

double SiPixelRecHitQuality::Packing::probX_1_over_log_units

Definition at line 33 of file SiPixelRecHitQuality.h.

Referenced by Packing(), and setProbabilityXY().

QualWordType SiPixelRecHitQuality::Packing::probX_mask

Definition at line 30 of file SiPixelRecHitQuality.h.

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

int SiPixelRecHitQuality::Packing::probX_shift

Definition at line 31 of file SiPixelRecHitQuality.h.

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

float SiPixelRecHitQuality::Packing::probX_units

Definition at line 32 of file SiPixelRecHitQuality.h.

Referenced by Packing(), and probabilityXY().

char SiPixelRecHitQuality::Packing::probX_width

Definition at line 34 of file SiPixelRecHitQuality.h.

Referenced by Packing().

double SiPixelRecHitQuality::Packing::probY_1_over_log_units

Definition at line 39 of file SiPixelRecHitQuality.h.

Referenced by Packing(), and setProbabilityQ().

QualWordType SiPixelRecHitQuality::Packing::probY_mask

Definition at line 36 of file SiPixelRecHitQuality.h.

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

int SiPixelRecHitQuality::Packing::probY_shift

Definition at line 37 of file SiPixelRecHitQuality.h.

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

float SiPixelRecHitQuality::Packing::probY_units

Definition at line 38 of file SiPixelRecHitQuality.h.

Referenced by Packing(), and probabilityQ().

char SiPixelRecHitQuality::Packing::probY_width

Definition at line 40 of file SiPixelRecHitQuality.h.

Referenced by Packing().

QualWordType SiPixelRecHitQuality::Packing::qBin_mask

Definition at line 42 of file SiPixelRecHitQuality.h.

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

int SiPixelRecHitQuality::Packing::qBin_shift

Definition at line 43 of file SiPixelRecHitQuality.h.

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

char SiPixelRecHitQuality::Packing::qBin_width

Definition at line 44 of file SiPixelRecHitQuality.h.

Referenced by Packing().

char SiPixelRecHitQuality::Packing::spare_width

Definition at line 62 of file SiPixelRecHitQuality.h.

Referenced by Packing().

QualWordType SiPixelRecHitQuality::Packing::twoROC_mask

Definition at line 54 of file SiPixelRecHitQuality.h.

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

int SiPixelRecHitQuality::Packing::twoROC_shift

Definition at line 55 of file SiPixelRecHitQuality.h.

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

char SiPixelRecHitQuality::Packing::twoROC_width

Definition at line 56 of file SiPixelRecHitQuality.h.

Referenced by Packing().