CMS 3D CMS Logo

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 12 of file SiPixelRecHitQuality.h.

Constructor & Destructor Documentation

◆ Packing()

SiPixelRecHitQuality::Packing::Packing ( )

Definition at line 5 of file SiPixelRecHitQuality.cc.

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 }

References bad_mask, bad_shift, bad_width, edge_mask, edge_shift, edge_width, Exception, hasFilledProb_mask, hasFilledProb_shift, hasFilledProb_width, dqm-mbProfile::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.

Member Function Documentation

◆ hasBadPixels()

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

Definition at line 100 of file SiPixelRecHitQuality.h.

100 { return (qualWord >> bad_shift) & bad_mask; }

References bad_mask, and bad_shift.

Referenced by SiPixelRecHit::hasBadPixels().

◆ hasFilledProb()

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

Definition at line 104 of file SiPixelRecHitQuality.h.

104  {
105  return (qualWord >> hasFilledProb_shift) & hasFilledProb_mask;
106  }

References hasFilledProb_mask, and hasFilledProb_shift.

Referenced by SiPixelRecHit::hasFilledProb().

◆ isOnEdge()

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

Definition at line 98 of file SiPixelRecHitQuality.h.

98 { return (qualWord >> edge_shift) & edge_mask; }

References edge_mask, and edge_shift.

Referenced by SiPixelRecHit::isOnEdge().

◆ probabilityQ()

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

Definition at line 76 of file SiPixelRecHitQuality.h.

76  {
77  int raw = (qualWord >> probY_shift) & probY_mask;
78  if (raw < 0 || raw > 255) {
79  warningOutOfBoundRaw("Q", raw, qualWord);
80  raw = 255;
81  }
82  float prob = (raw == 255) ? 0 : pow(probY_units, (float)(-raw));
83  // cout << "Bits = " << raw << " --> Prob = " << prob << endl;
84  return prob;
85  }

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

Referenced by SiPixelRecHit::probabilityQ().

◆ probabilityX()

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

Definition at line 57 of file SiPixelRecHitQuality.h.

57  {
59  return -10;
60  }

References SiPixelRecHitQuality::warningObsolete().

Referenced by SiPixelRecHit::probabilityX().

◆ probabilityXY()

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

Definition at line 66 of file SiPixelRecHitQuality.h.

66  {
67  int raw = (qualWord >> probX_shift) & probX_mask;
68  if (raw < 0 || raw > 16383) {
69  warningOutOfBoundRaw("XY", raw, qualWord);
70  raw = 16383;
71  }
72  float prob = (raw == 16383) ? 0 : pow(probX_units, (float)(-raw));
73  // cout << "Bits = " << raw << " --> Prob = " << prob << endl;
74  return prob;
75  }

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

Referenced by SiPixelRecHit::probabilityXY().

◆ probabilityY()

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

Definition at line 61 of file SiPixelRecHitQuality.h.

61  {
63  return -10;
64  }

References SiPixelRecHitQuality::warningObsolete().

Referenced by SiPixelRecHit::probabilityY().

◆ qBin()

int SiPixelRecHitQuality::Packing::qBin ( QualWordType  qualWord) const
inline

Definition at line 88 of file SiPixelRecHitQuality.h.

88  {
89  int qbin = (qualWord >> qBin_shift) & qBin_mask;
90  if (qbin < 0 || qbin > 7) {
91  warningOutOfBoundQbin(qbin, qualWord);
92  qbin = 0;
93  }
94  return qbin;
95  }

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

Referenced by SiPixelRecHit::qBin().

◆ setHasBadPixels()

void SiPixelRecHitQuality::Packing::setHasBadPixels ( bool  flag,
QualWordType qualWord 
) const
inline

Definition at line 142 of file SiPixelRecHitQuality.h.

142  {
143  qualWord |= ((flag & bad_mask) << bad_shift);
144  }

References bad_mask, bad_shift, and RemoveAddSevLevel::flag.

Referenced by PixelCPEBase::rawQualityWord().

◆ setHasFilledProb()

void SiPixelRecHitQuality::Packing::setHasFilledProb ( bool  flag,
QualWordType qualWord 
) const
inline

Definition at line 148 of file SiPixelRecHitQuality.h.

148  {
149  qualWord |= ((flag & hasFilledProb_mask) << hasFilledProb_shift);
150  }

References RemoveAddSevLevel::flag, hasFilledProb_mask, and hasFilledProb_shift.

Referenced by PixelCPEBase::rawQualityWord().

◆ setIsOnEdge()

void SiPixelRecHitQuality::Packing::setIsOnEdge ( bool  flag,
QualWordType qualWord 
) const
inline

Definition at line 141 of file SiPixelRecHitQuality.h.

141 { qualWord |= ((flag & edge_mask) << edge_shift); }

References edge_mask, edge_shift, and RemoveAddSevLevel::flag.

Referenced by PixelCPEBase::rawQualityWord().

◆ setProbabilityQ()

void SiPixelRecHitQuality::Packing::setProbabilityQ ( float  prob,
QualWordType qualWord 
) const
inline

Definition at line 122 of file SiPixelRecHitQuality.h.

122  {
123  if (prob < 0 || prob > 1) {
124  warningOutOfBoundProb("Q", prob, qualWord);
125  prob = 0;
126  }
127  double draw = (prob <= 1E-5) ? 255 : -log((double)prob) * probY_1_over_log_units;
128  unsigned int raw = (int)(draw + 0.5); // convert to integer, round correctly
129  // cout << "Prob = " << prob << " --> Bits = " << raw << endl;
130  qualWord |= ((raw & probY_mask) << probY_shift);
131  }

References ntuplePlotting::draw(), createfilelist::int, dqm-mbProfile::log, TtFullHadEvtBuilder_cfi::prob, probY_1_over_log_units, probY_mask, probY_shift, and SiPixelRecHitQuality::warningOutOfBoundProb().

Referenced by PixelCPEBase::rawQualityWord().

◆ setProbabilityXY()

void SiPixelRecHitQuality::Packing::setProbabilityXY ( float  prob,
QualWordType qualWord 
) const
inline

Definition at line 112 of file SiPixelRecHitQuality.h.

112  {
113  if (prob < 0 || prob > 1) {
114  warningOutOfBoundProb("XY", prob, qualWord);
115  prob = 0;
116  }
117  double draw = (prob <= 1.6E-13) ? 16383 : -log((double)prob) * probX_1_over_log_units;
118  unsigned int raw = (int)(draw + 0.5); // convert to integer, round correctly
119  // cout << "Prob = " << prob << " --> Bits = " << raw << endl;
120  qualWord |= ((raw & probX_mask) << probX_shift);
121  }

References ntuplePlotting::draw(), createfilelist::int, dqm-mbProfile::log, TtFullHadEvtBuilder_cfi::prob, probX_1_over_log_units, probX_mask, probX_shift, and SiPixelRecHitQuality::warningOutOfBoundProb().

Referenced by PixelCPEBase::rawQualityWord().

◆ setQBin()

void SiPixelRecHitQuality::Packing::setQBin ( int  qbin,
QualWordType qualWord 
) const
inline

Definition at line 133 of file SiPixelRecHitQuality.h.

133  {
134  if (qbin < 0 || qbin > 7) {
135  warningOutOfBoundQbin(qbin, qualWord);
136  qbin = 0;
137  }
138  qualWord |= ((qbin & qBin_mask) << qBin_shift);
139  }

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

Referenced by PixelCPEBase::rawQualityWord().

◆ setSpansTwoROCs()

void SiPixelRecHitQuality::Packing::setSpansTwoROCs ( bool  flag,
QualWordType qualWord 
) const
inline

Definition at line 145 of file SiPixelRecHitQuality.h.

145  {
146  qualWord |= ((flag & twoROC_mask) << twoROC_shift);
147  }

References RemoveAddSevLevel::flag, twoROC_mask, and twoROC_shift.

Referenced by PixelCPEBase::rawQualityWord().

◆ spansTwoROCs()

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

Definition at line 102 of file SiPixelRecHitQuality.h.

102 { return (qualWord >> twoROC_shift) & twoROC_mask; }

References twoROC_mask, and twoROC_shift.

Referenced by SiPixelRecHit::spansTwoROCs().

Member Data Documentation

◆ bad_mask

QualWordType SiPixelRecHitQuality::Packing::bad_mask

Definition at line 38 of file SiPixelRecHitQuality.h.

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

◆ bad_shift

int SiPixelRecHitQuality::Packing::bad_shift

Definition at line 39 of file SiPixelRecHitQuality.h.

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

◆ bad_width

char SiPixelRecHitQuality::Packing::bad_width

Definition at line 40 of file SiPixelRecHitQuality.h.

Referenced by Packing().

◆ edge_mask

QualWordType SiPixelRecHitQuality::Packing::edge_mask

Definition at line 34 of file SiPixelRecHitQuality.h.

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

◆ edge_shift

int SiPixelRecHitQuality::Packing::edge_shift

Definition at line 35 of file SiPixelRecHitQuality.h.

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

◆ edge_width

char SiPixelRecHitQuality::Packing::edge_width

Definition at line 36 of file SiPixelRecHitQuality.h.

Referenced by Packing().

◆ hasFilledProb_mask

QualWordType SiPixelRecHitQuality::Packing::hasFilledProb_mask

Definition at line 46 of file SiPixelRecHitQuality.h.

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

◆ hasFilledProb_shift

int SiPixelRecHitQuality::Packing::hasFilledProb_shift

Definition at line 47 of file SiPixelRecHitQuality.h.

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

◆ hasFilledProb_width

char SiPixelRecHitQuality::Packing::hasFilledProb_width

Definition at line 48 of file SiPixelRecHitQuality.h.

Referenced by Packing().

◆ probX_1_over_log_units

double SiPixelRecHitQuality::Packing::probX_1_over_log_units

Definition at line 21 of file SiPixelRecHitQuality.h.

Referenced by Packing(), and setProbabilityXY().

◆ probX_mask

QualWordType SiPixelRecHitQuality::Packing::probX_mask

Definition at line 18 of file SiPixelRecHitQuality.h.

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

◆ probX_shift

int SiPixelRecHitQuality::Packing::probX_shift

Definition at line 19 of file SiPixelRecHitQuality.h.

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

◆ probX_units

float SiPixelRecHitQuality::Packing::probX_units

Definition at line 20 of file SiPixelRecHitQuality.h.

Referenced by Packing(), and probabilityXY().

◆ probX_width

char SiPixelRecHitQuality::Packing::probX_width

Definition at line 22 of file SiPixelRecHitQuality.h.

Referenced by Packing().

◆ probY_1_over_log_units

double SiPixelRecHitQuality::Packing::probY_1_over_log_units

Definition at line 27 of file SiPixelRecHitQuality.h.

Referenced by Packing(), and setProbabilityQ().

◆ probY_mask

QualWordType SiPixelRecHitQuality::Packing::probY_mask

Definition at line 24 of file SiPixelRecHitQuality.h.

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

◆ probY_shift

int SiPixelRecHitQuality::Packing::probY_shift

Definition at line 25 of file SiPixelRecHitQuality.h.

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

◆ probY_units

float SiPixelRecHitQuality::Packing::probY_units

Definition at line 26 of file SiPixelRecHitQuality.h.

Referenced by Packing(), and probabilityQ().

◆ probY_width

char SiPixelRecHitQuality::Packing::probY_width

Definition at line 28 of file SiPixelRecHitQuality.h.

Referenced by Packing().

◆ qBin_mask

QualWordType SiPixelRecHitQuality::Packing::qBin_mask

Definition at line 30 of file SiPixelRecHitQuality.h.

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

◆ qBin_shift

int SiPixelRecHitQuality::Packing::qBin_shift

Definition at line 31 of file SiPixelRecHitQuality.h.

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

◆ qBin_width

char SiPixelRecHitQuality::Packing::qBin_width

Definition at line 32 of file SiPixelRecHitQuality.h.

Referenced by Packing().

◆ spare_width

char SiPixelRecHitQuality::Packing::spare_width

Definition at line 50 of file SiPixelRecHitQuality.h.

Referenced by Packing().

◆ twoROC_mask

QualWordType SiPixelRecHitQuality::Packing::twoROC_mask

Definition at line 42 of file SiPixelRecHitQuality.h.

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

◆ twoROC_shift

int SiPixelRecHitQuality::Packing::twoROC_shift

Definition at line 43 of file SiPixelRecHitQuality.h.

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

◆ twoROC_width

char SiPixelRecHitQuality::Packing::twoROC_width

Definition at line 44 of file SiPixelRecHitQuality.h.

Referenced by Packing().

SiPixelRecHitQuality::Packing::probX_1_over_log_units
double probX_1_over_log_units
Definition: SiPixelRecHitQuality.h:21
SiPixelRecHitQuality::Packing::probY_mask
QualWordType probY_mask
Definition: SiPixelRecHitQuality.h:24
SiPixelRecHitQuality::Packing::probY_width
char probY_width
Definition: SiPixelRecHitQuality.h:28
SiPixelRecHitQuality::Packing::qBin_mask
QualWordType qBin_mask
Definition: SiPixelRecHitQuality.h:30
SiPixelRecHitQuality::Packing::probY_units
float probY_units
Definition: SiPixelRecHitQuality.h:26
SiPixelRecHitQuality::Packing::edge_shift
int edge_shift
Definition: SiPixelRecHitQuality.h:35
SiPixelRecHitQuality::warningOutOfBoundQbin
static void warningOutOfBoundQbin(int, QualWordType const &)
Definition: SiPixelRecHitQuality.cc:61
ntuplePlotting.draw
def draw(name, histos, styles=_defaultStyles, legendLabels=[], **kwargs)
Definition: ntuplePlotting.py:24
SiPixelRecHitQuality::Packing::probY_1_over_log_units
double probY_1_over_log_units
Definition: SiPixelRecHitQuality.h:27
SiPixelRecHitQuality::Packing::probX_width
char probX_width
Definition: SiPixelRecHitQuality.h:22
SiPixelRecHitQuality::Packing::bad_mask
QualWordType bad_mask
Definition: SiPixelRecHitQuality.h:38
SiPixelRecHitQuality::Packing::probX_mask
QualWordType probX_mask
Definition: SiPixelRecHitQuality.h:18
SiPixelRecHitQuality::Packing::qBin_shift
int qBin_shift
Definition: SiPixelRecHitQuality.h:31
SiPixelRecHitQuality::QualWordType
unsigned int QualWordType
Definition: SiPixelRecHitQuality.h:9
SiPixelRecHitQuality::Packing::twoROC_shift
int twoROC_shift
Definition: SiPixelRecHitQuality.h:43
SiPixelRecHitQuality::warningOutOfBoundProb
static void warningOutOfBoundProb(const char *iVariable, float, QualWordType const &)
Definition: SiPixelRecHitQuality.cc:66
SiPixelRecHitQuality::warningOutOfBoundRaw
static void warningOutOfBoundRaw(const char *iVariable, int iRaw, QualWordType const &)
Definition: SiPixelRecHitQuality.cc:72
SiPixelRecHitQuality::Packing::probX_shift
int probX_shift
Definition: SiPixelRecHitQuality.h:19
createfilelist.int
int
Definition: createfilelist.py:10
SiPixelRecHitQuality::Packing::spare_width
char spare_width
Definition: SiPixelRecHitQuality.h:50
SiPixelRecHitQuality::Packing::edge_mask
QualWordType edge_mask
Definition: SiPixelRecHitQuality.h:34
SiPixelRecHitQuality::Packing::bad_shift
int bad_shift
Definition: SiPixelRecHitQuality.h:39
SiPixelRecHitQuality::Packing::bad_width
char bad_width
Definition: SiPixelRecHitQuality.h:40
SiPixelRecHitQuality::Packing::edge_width
char edge_width
Definition: SiPixelRecHitQuality.h:36
Exception
Definition: hltDiff.cc:245
SiPixelRecHitQuality::Packing::twoROC_width
char twoROC_width
Definition: SiPixelRecHitQuality.h:44
dqm-mbProfile.log
log
Definition: dqm-mbProfile.py:17
SiPixelRecHitQuality::Packing::probY_shift
int probY_shift
Definition: SiPixelRecHitQuality.h:25
SiPixelRecHitQuality::Packing::hasFilledProb_width
char hasFilledProb_width
Definition: SiPixelRecHitQuality.h:48
SiPixelRecHitQuality::Packing::probX_units
float probX_units
Definition: SiPixelRecHitQuality.h:20
funct::pow
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:29
TtFullHadEvtBuilder_cfi.prob
prob
Definition: TtFullHadEvtBuilder_cfi.py:33
SiPixelRecHitQuality::warningObsolete
static void warningObsolete()
Definition: SiPixelRecHitQuality.cc:56
SiPixelRecHitQuality::Packing::hasFilledProb_mask
QualWordType hasFilledProb_mask
Definition: SiPixelRecHitQuality.h:46
RemoveAddSevLevel.flag
flag
Definition: RemoveAddSevLevel.py:117
SiPixelRecHitQuality::Packing::hasFilledProb_shift
int hasFilledProb_shift
Definition: SiPixelRecHitQuality.h:47
SiPixelRecHitQuality::Packing::twoROC_mask
QualWordType twoROC_mask
Definition: SiPixelRecHitQuality.h:42
SiPixelRecHitQuality::Packing::qBin_width
char qBin_width
Definition: SiPixelRecHitQuality.h:32