20 #ifndef CondFormatsL1TObjects_L1MuPacking_h 21 #define CondFormatsL1TObjects_L1MuPacking_h 56 template <
unsigned int Bits>
62 int idxFromPacked(
unsigned packed)
const override {
return (
int)packed; };
65 if (
idx >= (1 << Bits))
67 <<
"L1MuUnignedPacking::packedFromIdx: warning value " <<
idx <<
"exceeds " << Bits <<
"-bit range !!!";
75 static int signFromPacked(
unsigned packed,
unsigned int nbits) {
return 0; };
77 static int idxFromPacked(
unsigned packed,
unsigned int nbits) {
return (
int)packed; };
80 if (
idx >= (1 << nbits))
82 <<
"L1MuUnignedPacking::packedFromIdx: warning value " <<
idx <<
"exceeds " << nbits <<
"-bit range !!!";
98 template <
unsigned int Bits>
102 int signFromPacked(
unsigned packed)
const override {
return packed & (1 << (Bits - 1)) ? 1 : 0; };
106 return packed & (1 << (Bits - 1)) ? (packed - (1 << Bits)) : packed;
110 unsigned maxabs = 1
U << (Bits - 1);
111 if (
idx < -(
int)maxabs &&
idx >= (
int)maxabs)
113 <<
"L1MuSignedPacking::packedFromIdx: warning value " <<
idx <<
"exceeds " << Bits <<
"-bit range !!!";
121 static int signFromPacked(
unsigned packed,
unsigned int nbits) {
return packed & (1 << (nbits - 1)) ? 1 : 0; };
125 return packed & (1 << (nbits - 1)) ? (packed - (1 << nbits)) : packed;
129 unsigned maxabs = 1
U << (nbits - 1);
130 if (
idx < -(
int)maxabs &&
idx >= (
int)maxabs)
132 <<
"L1MuSignedPacking::packedFromIdx: warning value " <<
idx <<
"exceeds " << nbits <<
"-bit range !!!";
162 int absidx = (
int)(packed &
mask);
163 unsigned psmask = (1 << (
m_nbits - 1));
164 return absidx * (((packed & psmask) == psmask) ? -1 : 1);
169 unsigned maxabs = (1 << (
m_nbits - 1)) - 1;
171 edm::LogWarning(
"ScaleRangeViolation") <<
"L1MuPseudoSignedPacking::packedFromIdx: warning value " <<
idx 172 <<
"exceeds " <<
m_nbits <<
"-bit range !!!";
181 unsigned maxabs = (1 << (
m_nbits - 1)) - 1;
183 edm::LogWarning(
"ScaleRangeViolation") <<
"L1MuPseudoSignedPacking::packedFromIdx: warning value " <<
idx 184 <<
"exceeds " <<
m_nbits <<
"-bit range !!!";
L1MuPseudoSignedPacking()
static int idxFromPacked(unsigned packed, unsigned int nbits)
get the value from the packed notation (always positive)
static int signFromPacked(unsigned packed, unsigned int nbits)
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)
unsigned packedFromIdx(int idx) const override
get the packed notation of a value, check the range
static unsigned packedFromIdx(int idx, unsigned int nbits)
get the packed notation of a value, check 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 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 (+/-)
int idxFromPacked(unsigned packed) const override
get the value from the packed notation (+/-)
Abs< T >::type abs(const T &t)
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 (+/-)
virtual int idxFromPacked(unsigned packed) const =0
get the value from the packed notation
int signFromPacked(unsigned packed) const override
get the (pseudo-)sign from the packed notation (0=positive, 1=negative)
int signFromPacked(unsigned packed) const override
get the sign from the packed notation (0=positive, 1=negative)
#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
unsigned packedFromIdx(int idx) const override
get the packed notation of a value, check range
Log< level::Warning, false > LogWarning
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)