21 #ifndef CondFormatsL1TObjects_L1MuPacking_h
22 #define CondFormatsL1TObjects_L1MuPacking_h
48 template<
unsigned int Bits>
54 virtual int idxFromPacked(
unsigned packed)
const {
return (
int) packed;};
58 <<
"L1MuUnignedPacking::packedFromIdx: warning value " << idx
59 <<
"exceeds " <<
Bits <<
"-bit range !!!";
60 return (
unsigned)
idx;
69 static int idxFromPacked(
unsigned packed,
unsigned int nbits) {
return (
int) packed;};
73 <<
"L1MuUnignedPacking::packedFromIdx: warning value " << idx
74 <<
"exceeds " << nbits <<
"-bit range !!!";
75 return (
unsigned)
idx;
85 template<
unsigned int Bits>
92 virtual int idxFromPacked(
unsigned packed)
const {
return packed & (1 << (
Bits-1)) ? (packed - (1 <<
Bits) ) : packed;};
95 unsigned maxabs = 1 << (
Bits-1) ;
96 if (idx < -(
int)maxabs && idx >= (int)maxabs)
edm::LogWarning(
"ScaleRangeViolation")
97 <<
"L1MuSignedPacking::packedFromIdx: warning value " << idx
98 <<
"exceeds " <<
Bits <<
"-bit range !!!";
99 return ~(~0 <<
Bits) & (idx < 0 ? (1 << Bits) + idx :
idx);
106 static int signFromPacked(
unsigned packed,
unsigned int nbits) {
return packed & (1 << (nbits-1)) ? 1 : 0;};
109 static int idxFromPacked(
unsigned packed,
unsigned int nbits) {
return packed & (1 << (nbits-1)) ? (packed - (1 << nbits) ) : packed;};
112 unsigned maxabs = 1 << (nbits-1) ;
113 if (idx < -(
int)maxabs && idx >= (int)maxabs)
edm::LogWarning(
"ScaleRangeViolation")
114 <<
"L1MuSignedPacking::packedFromIdx: warning value " << idx
115 <<
"exceeds " << nbits <<
"-bit range !!!";
116 return ~(~0 << nbits) & (idx < 0 ? (1 << nbits) + idx :
idx);
139 unsigned mask = (1 << (
m_nbits-1)) - 1;
140 int absidx = (int) ( packed & mask );
141 unsigned psmask = (1 << (
m_nbits-1) );
142 return absidx * ( ( (packed & psmask) == psmask ) ? -1 : 1 );
146 unsigned packed =
abs(idx);
147 unsigned maxabs = (1 << (
m_nbits-1)) -1;
149 <<
"L1MuPseudoSignedPacking::packedFromIdx: warning value " << idx
150 <<
"exceeds " <<
m_nbits <<
"-bit range !!!";
151 if (idx < 0) packed |= 1 << (m_nbits-1);
157 unsigned packed =
abs(idx);
158 unsigned maxabs = (1 << (
m_nbits-1)) -1;
160 <<
"L1MuPseudoSignedPacking::packedFromIdx: warning value " << idx
161 <<
"exceeds " <<
m_nbits <<
"-bit range !!!";
162 if (sig==1) packed |= 1 << (m_nbits-1);
L1MuPseudoSignedPacking()
static int idxFromPacked(unsigned packed, unsigned int nbits)
get the value from the packed notation (always positive)
virtual unsigned packedFromIdx(int idx) const
get the packed notation of a value, check the range
virtual unsigned packedFromIdx(int idx) const
get the packed notation of a value, check range
static int signFromPacked(unsigned packed, unsigned int nbits)
get the sign from the packed notation. always psitive (0)
virtual int signFromPacked(unsigned packed) const
get the sign from the packed notation. always psitive (0)
virtual int idxFromPacked(unsigned packed) const
get the value from the packed notation (+/-)
virtual int signFromPacked(unsigned packed) const
get the sign from the packed notation (0=positive, 1=negative)
static unsigned packedFromIdx(int idx, unsigned int nbits)
get the packed notation of a value, check range
virtual unsigned packedFromIdx(int idx) const =0
get the packed notation of a value
static int idxFromPacked(unsigned packed, unsigned int nbits)
get the value from the packed notation (+/-)
virtual unsigned packedFromIdx(int idx) const
get the packed notation of a value, check range
virtual int idxFromPacked(unsigned packed) const =0
get the value from the packed notation
virtual ~L1MuPseudoSignedPacking()
tuple idx
DEBUGGING if hasattr(process,"trackMonIterativeTracking2012"): print "trackMonIterativeTracking2012 D...
virtual int idxFromPacked(unsigned packed) const
get the value from the packed notation (+/-)
L1MuPseudoSignedPacking(unsigned int nbits)
static unsigned packedFromIdx(int idx, unsigned int nbits)
get the packed notation of a value, check the range
virtual unsigned packedFromIdx(int idx, int sig) const
get the packed notation of a value, check range; sets the sign separately, 1 is neg. sign(!)
virtual int idxFromPacked(unsigned packed) const
get the value from the packed notation (always positive)
virtual int signFromPacked(unsigned packed) const
get the (pseudo-)sign from the packed notation (0=positive, 1=negative)
static int signFromPacked(unsigned packed, unsigned int nbits)
get the sign from the packed notation (0=positive, 1=negative)
virtual int signFromPacked(unsigned packed) const =0
get the sign from the packed notation (0=positive, 1=negative)