21 #ifndef CondFormatsL1TObjects_L1MuPacking_h 22 #define CondFormatsL1TObjects_L1MuPacking_h 56 template<
unsigned int Bits>
62 int idxFromPacked(
unsigned packed)
const override {
return (
int) packed;};
66 <<
"L1MuUnignedPacking::packedFromIdx: warning value " << idx
67 <<
"exceeds " <<
Bits <<
"-bit range !!!";
68 return (
unsigned)
idx;
77 static int idxFromPacked(
unsigned packed,
unsigned int nbits) {
return (
int) packed;};
81 <<
"L1MuUnignedPacking::packedFromIdx: warning value " << idx
82 <<
"exceeds " << nbits <<
"-bit range !!!";
83 return (
unsigned)
idx;
93 template<
unsigned int Bits>
100 int idxFromPacked(
unsigned packed)
const override {
return packed & (1 << (
Bits-1)) ? (packed - (1 <<
Bits) ) : packed;};
103 unsigned maxabs = 1 << (
Bits-1) ;
105 <<
"L1MuSignedPacking::packedFromIdx: warning value " << idx
106 <<
"exceeds " <<
Bits <<
"-bit range !!!";
107 return ~(~0 <<
Bits) & (idx < 0 ? (1 << Bits) + idx :
idx);
114 static int signFromPacked(
unsigned packed,
unsigned int nbits) {
return packed & (1 << (nbits-1)) ? 1 : 0;};
117 static int idxFromPacked(
unsigned packed,
unsigned int nbits) {
return packed & (1 << (nbits-1)) ? (packed - (1 << nbits) ) : packed;};
120 unsigned maxabs = 1 << (nbits-1) ;
122 <<
"L1MuSignedPacking::packedFromIdx: warning value " << idx
123 <<
"exceeds " << nbits <<
"-bit range !!!";
124 return ~(~0 << nbits) & (idx < 0 ? (1 << nbits) + idx :
idx);
143 int signFromPacked(
unsigned packed)
const override {
return ( packed & (1 << (m_nbits-1)) ) ? 1 : 0;};
147 unsigned mask = (1 << (m_nbits-1)) - 1;
148 int absidx = (
int) ( packed & mask );
149 unsigned psmask = (1 << (m_nbits-1) );
150 return absidx * ( ( (packed & psmask) == psmask ) ? -1 : 1 );
155 unsigned maxabs = (1 << (m_nbits-1)) -1;
157 <<
"L1MuPseudoSignedPacking::packedFromIdx: warning value " << idx
158 <<
"exceeds " << m_nbits <<
"-bit range !!!";
159 if (idx < 0) packed |= 1 << (m_nbits-1);
166 unsigned maxabs = (1 << (m_nbits-1)) -1;
168 <<
"L1MuPseudoSignedPacking::packedFromIdx: warning value " << idx
169 <<
"exceeds " << m_nbits <<
"-bit range !!!";
170 if (sig==1) packed |= 1 << (m_nbits-1);
L1MuPseudoSignedPacking()
int signFromPacked(unsigned packed) const override
get the sign from the packed notation (0=positive, 1=negative)
static int idxFromPacked(unsigned packed, unsigned int nbits)
get the value from the packed notation (always positive)
virtual int signFromPacked(unsigned packed) const =0
get the sign from the packed notation (0=positive, 1=negative)
static int signFromPacked(unsigned packed, unsigned int nbits)
get the sign from the packed notation. always psitive (0)
int signFromPacked(unsigned packed) const override
get the (pseudo-)sign from the packed notation (0=positive, 1=negative)
unsigned packedFromIdx(int idx) const override
get the packed notation of a value, check range
int idxFromPacked(unsigned packed) const override
get the value from the packed notation (+/-)
int idxFromPacked(unsigned packed) const override
get the value from the packed notation (+/-)
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
unsigned packedFromIdx(int idx) const override
get the packed notation of a value, check the range
static int idxFromPacked(unsigned packed, unsigned int nbits)
get the value from the packed notation (+/-)
Abs< T >::type abs(const T &t)
virtual int idxFromPacked(unsigned packed) const =0
get the value from the packed notation
#define COND_SERIALIZABLE
L1MuPseudoSignedPacking(unsigned int nbits)
unsigned packedFromIdx(int idx) const override
get the packed notation of a value, check range
~L1MuPseudoSignedPacking() override
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(!)
int signFromPacked(unsigned packed) const override
get the sign from the packed notation. always psitive (0)
int idxFromPacked(unsigned packed) const override
get the value from the packed notation (always positive)
static int signFromPacked(unsigned packed, unsigned int nbits)
get the sign from the packed notation (0=positive, 1=negative)