00001 #ifndef DataFormats_SiPixelRecHitQuality_h
00002 #define DataFormats_SiPixelRecHitQuality_h 1
00003
00004
00005 #include <math.h>
00006
00007
00008 #include <utility>
00009
00010
00011 #include <boost/cstdint.hpp>
00012
00013
00014 class SiPixelRecHitQuality {
00015 public:
00016 typedef uint32_t QualWordType;
00017
00018
00019 public:
00020
00021 class Packing {
00022 public:
00023
00024
00025 Packing();
00026
00027 public:
00028 QualWordType probX_mask;
00029 int probX_shift;
00030 float probX_units;
00031 char probX_width;
00032
00033 QualWordType probY_mask;
00034 int probY_shift;
00035 float probY_units;
00036 char probY_width;
00037
00038 QualWordType cotAlpha_mask;
00039 int cotAlpha_shift;
00040 float cotAlpha_units;
00041 char cotAlpha_width;
00042
00043 QualWordType cotBeta_mask;
00044 int cotBeta_shift;
00045 float cotBeta_units;
00046 char cotBeta_width;
00047
00048 QualWordType qBin_mask;
00049 int qBin_shift;
00050 char qBin_width;
00051
00052 QualWordType edge_mask;
00053 int edge_shift;
00054 char edge_width;
00055
00056 QualWordType bad_mask;
00057 int bad_shift;
00058 char bad_width;
00059
00060 QualWordType twoROC_mask;
00061 int twoROC_shift;
00062 char twoROC_width;
00063
00064 char spare_width;
00065
00066 inline float cotAlphaFromCluster( QualWordType qualWord ) const {
00067 int raw = (qualWord >> cotAlpha_shift) & cotAlpha_mask;
00068 return raw * cotAlpha_units;
00069 }
00070 inline float cotBetaFromCluster( QualWordType qualWord ) const {
00071 int raw = (qualWord >> cotBeta_shift) & cotBeta_mask;
00072 return raw * cotBeta_units;
00073 }
00074
00075
00076
00077
00078 inline float probabilityX( QualWordType qualWord ) const {
00079 int raw = (qualWord >> probX_shift) & probX_mask;
00080 float prob = pow(10.0, (double)-raw * probX_units);
00081 return prob;
00082 }
00083 inline float probabilityY( QualWordType qualWord ) const {
00084 int raw = (qualWord >> probY_shift) & probY_mask;
00085 float prob = pow(10.0, (double)-raw * probY_units);
00086 return prob;
00087 }
00088
00089 inline int qBin( QualWordType qualWord ) const {
00090 return (qualWord >> qBin_shift) & qBin_mask;
00091 }
00092
00093
00094 inline bool isOnEdge( QualWordType qualWord ) const {
00095 return (qualWord >> edge_shift) & edge_mask;
00096 }
00097
00098 inline bool hasBadPixels( QualWordType qualWord ) const {
00099 return (qualWord >> bad_shift) & bad_mask;
00100 }
00101
00102 inline bool spansTwoROCs( QualWordType qualWord ) const {
00103 return (qualWord >> twoROC_shift) & twoROC_mask;
00104 }
00105
00106
00107
00108
00109
00110
00111 inline void setCotAlphaFromCluster( float cotalpha, QualWordType & qualWord ) {
00112 int raw = (int) (cotalpha/cotAlpha_units);
00113 qualWord &= ((raw & cotAlpha_mask) << cotAlpha_shift);
00114 }
00115 inline void setCotBetaFromCluster( float cotbeta, QualWordType & qualWord ) {
00116 int raw = (int) (cotbeta/cotBeta_units);
00117 qualWord &= ((raw & cotBeta_mask) << cotBeta_shift);
00118 }
00119
00120
00121 inline void setProbabilityX( float prob, QualWordType & qualWord ) {
00122 int raw = (int) (prob/probX_units);
00123 qualWord &= ((raw & probX_mask) << probX_shift);
00124 }
00125 inline void setProbabilityY( float prob, QualWordType & qualWord ) {
00126 int raw = (int) (prob/probY_units);
00127 qualWord &= ((raw & probY_mask) << probY_shift);
00128 }
00129
00130 inline void setQBin( int qbin, QualWordType & qualWord ) {
00131 qualWord &= ((qbin & qBin_mask) << qBin_shift);
00132 }
00133
00134 inline void setIsOnEdge( bool flag, QualWordType & qualWord ) {
00135 qualWord &= ((flag & edge_mask) << edge_shift);
00136 }
00137 inline void setHasBadPixels( bool flag, QualWordType & qualWord ) {
00138 qualWord &= ((flag & bad_mask) << bad_shift);
00139 }
00140 inline void setSpansTwoROCs( bool flag, QualWordType & qualWord ) {
00141 qualWord &= ((flag & twoROC_mask) << twoROC_shift);
00142 }
00143
00144 };
00145
00146
00147 public:
00148 static Packing thePacking;
00149 };
00150
00151
00152 #endif