21 #ifndef CondFormatsL1TObjects_L1MuPacking_h
22 #define CondFormatsL1TObjects_L1MuPacking_h
49 template<
unsigned int Bits>
55 virtual int idxFromPacked(
unsigned packed)
const {
return (
int) packed;};
59 <<
"L1MuUnignedPacking::packedFromIdx: warning value " << idx
60 <<
"exceeds " <<
Bits <<
"-bit range !!!";
61 return (
unsigned)
idx;
70 static int idxFromPacked(
unsigned packed,
unsigned int nbits) {
return (
int) packed;};
74 <<
"L1MuUnignedPacking::packedFromIdx: warning value " << idx
75 <<
"exceeds " << nbits <<
"-bit range !!!";
76 return (
unsigned)
idx;
86 template<
unsigned int Bits>
93 virtual int idxFromPacked(
unsigned packed)
const {
return packed & (1 << (
Bits-1)) ? (packed - (1 <<
Bits) ) : packed;};
96 unsigned maxabs = 1 << (
Bits-1) ;
97 if (idx < -(
int)maxabs && idx >= (int)maxabs)
edm::LogWarning(
"ScaleRangeViolation")
98 <<
"L1MuSignedPacking::packedFromIdx: warning value " << idx
99 <<
"exceeds " <<
Bits <<
"-bit range !!!";
100 return ~(~0 <<
Bits) & (idx < 0 ? (1 << Bits) + idx :
idx);
107 static int signFromPacked(
unsigned packed,
unsigned int nbits) {
return packed & (1 << (nbits-1)) ? 1 : 0;};
110 static int idxFromPacked(
unsigned packed,
unsigned int nbits) {
return packed & (1 << (nbits-1)) ? (packed - (1 << nbits) ) : packed;};
113 unsigned maxabs = 1 << (nbits-1) ;
114 if (idx < -(
int)maxabs && idx >= (int)maxabs)
edm::LogWarning(
"ScaleRangeViolation")
115 <<
"L1MuSignedPacking::packedFromIdx: warning value " << idx
116 <<
"exceeds " << nbits <<
"-bit range !!!";
117 return ~(~0 << nbits) & (idx < 0 ? (1 << nbits) + idx :
idx);
140 unsigned mask = (1 << (
m_nbits-1)) - 1;
141 int absidx = (int) ( packed & mask );
142 unsigned psmask = (1 << (
m_nbits-1) );
143 return absidx * ( ( (packed & psmask) == psmask ) ? -1 : 1 );
147 unsigned packed =
abs(idx);
148 unsigned maxabs = (1 << (
m_nbits-1)) -1;
150 <<
"L1MuPseudoSignedPacking::packedFromIdx: warning value " << idx
151 <<
"exceeds " <<
m_nbits <<
"-bit range !!!";
152 if (idx < 0) packed |= 1 << (m_nbits-1);
158 unsigned packed =
abs(idx);
159 unsigned maxabs = (1 << (
m_nbits-1)) -1;
161 <<
"L1MuPseudoSignedPacking::packedFromIdx: warning value " << idx
162 <<
"exceeds " <<
m_nbits <<
"-bit range !!!";
163 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 (+/-)
Abs< T >::type abs(const T &t)
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)