21 #ifndef CondFormatsL1TObjects_L1MuPacking_h 22 #define CondFormatsL1TObjects_L1MuPacking_h 57 template<
unsigned int Bits>
63 int idxFromPacked(
unsigned packed)
const override {
return (
int) packed;};
67 <<
"L1MuUnignedPacking::packedFromIdx: warning value " << idx
68 <<
"exceeds " <<
Bits <<
"-bit range !!!";
69 return (
unsigned)
idx;
78 static int idxFromPacked(
unsigned packed,
unsigned int nbits) {
return (
int) packed;};
82 <<
"L1MuUnignedPacking::packedFromIdx: warning value " << idx
83 <<
"exceeds " << nbits <<
"-bit range !!!";
84 return (
unsigned)
idx;
94 template<
unsigned int Bits>
101 int idxFromPacked(
unsigned packed)
const override {
return packed & (1 << (
Bits-1)) ? (packed - (1 <<
Bits) ) : packed;};
104 unsigned maxabs = 1
U << (
Bits-1) ;
106 <<
"L1MuSignedPacking::packedFromIdx: warning value " << idx
107 <<
"exceeds " <<
Bits <<
"-bit range !!!";
115 static int signFromPacked(
unsigned packed,
unsigned int nbits) {
return packed & (1 << (nbits-1)) ? 1 : 0;};
118 static int idxFromPacked(
unsigned packed,
unsigned int nbits) {
return packed & (1 << (nbits-1)) ? (packed - (1 << nbits) ) : packed;};
121 unsigned maxabs = 1
U << (nbits-1) ;
123 <<
"L1MuSignedPacking::packedFromIdx: warning value " << idx
124 <<
"exceeds " << nbits <<
"-bit range !!!";
144 int signFromPacked(
unsigned packed)
const override {
return ( packed & (1 << (m_nbits-1)) ) ? 1 : 0;};
148 unsigned mask = (1 << (m_nbits-1)) - 1;
149 int absidx = (
int) ( packed & mask );
150 unsigned psmask = (1 << (m_nbits-1) );
151 return absidx * ( ( (packed & psmask) == psmask ) ? -1 : 1 );
156 unsigned maxabs = (1 << (m_nbits-1)) -1;
158 <<
"L1MuPseudoSignedPacking::packedFromIdx: warning value " << idx
159 <<
"exceeds " << m_nbits <<
"-bit range !!!";
160 if (idx < 0) packed |= 1 << (m_nbits-1);
167 unsigned maxabs = (1 << (m_nbits-1)) -1;
169 <<
"L1MuPseudoSignedPacking::packedFromIdx: warning value " << idx
170 <<
"exceeds " << m_nbits <<
"-bit range !!!";
171 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)