CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Private Attributes
L1MuPseudoSignedPacking Class Reference

#include <L1MuPacking.h>

Inheritance diagram for L1MuPseudoSignedPacking:
L1MuPacking

Public Member Functions

virtual int idxFromPacked (unsigned packed) const
 get the value from the packed notation (+/-) More...
 
 L1MuPseudoSignedPacking ()
 
 L1MuPseudoSignedPacking (unsigned int nbits)
 
virtual unsigned packedFromIdx (int idx) const
 get the packed notation of a value, check range More...
 
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(!) More...
 
virtual int signFromPacked (unsigned packed) const
 get the (pseudo-)sign from the packed notation (0=positive, 1=negative) More...
 
virtual ~L1MuPseudoSignedPacking ()
 

Private Attributes

unsigned int m_nbits
 

Detailed Description

Packing of a signed int in a bit field (pseudo-sign)

There is a -0 and a +0 in the pseudo-signed scale

Definition at line 128 of file L1MuPacking.h.

Constructor & Destructor Documentation

L1MuPseudoSignedPacking::L1MuPseudoSignedPacking ( )
inline

Definition at line 130 of file L1MuPacking.h.

130 {}
virtual L1MuPseudoSignedPacking::~L1MuPseudoSignedPacking ( )
inlinevirtual

Definition at line 131 of file L1MuPacking.h.

131 {};
L1MuPseudoSignedPacking::L1MuPseudoSignedPacking ( unsigned int  nbits)
inline

Definition at line 132 of file L1MuPacking.h.

132 : m_nbits(nbits) {};

Member Function Documentation

virtual int L1MuPseudoSignedPacking::idxFromPacked ( unsigned  packed) const
inlinevirtual

get the value from the packed notation (+/-)

Implements L1MuPacking.

Definition at line 138 of file L1MuPacking.h.

References m_nbits.

Referenced by L1MuSymmetricBinnedScale::getCenter(), and L1MuSymmetricBinnedScale::getLowEdge().

138  {
139  unsigned mask = (1 << (m_nbits-1)) - 1; // for lower bits
140  int absidx = (int) ( packed & mask );
141  unsigned psmask = (1 << (m_nbits-1) );
142  return absidx * ( ( (packed & psmask) == psmask ) ? -1 : 1 ); // pseudo sign==1 is negative
143  };
virtual unsigned L1MuPseudoSignedPacking::packedFromIdx ( int  idx) const
inlinevirtual

get the packed notation of a value, check range

Implements L1MuPacking.

Definition at line 145 of file L1MuPacking.h.

References abs, and m_nbits.

Referenced by L1MuSymmetricBinnedScale::getPacked().

145  {
146  unsigned packed = abs(idx);
147  unsigned maxabs = (1 << (m_nbits-1)) -1;
148  if (packed > maxabs) edm::LogWarning("ScaleRangeViolation")
149  << "L1MuPseudoSignedPacking::packedFromIdx: warning value " << idx
150  << "exceeds " << m_nbits << "-bit range !!!";
151  if (idx < 0) packed |= 1 << (m_nbits-1);
152  return packed;
153  }
#define abs(x)
Definition: mlp_lapack.h:159
tuple idx
DEBUGGING if hasattr(process,&quot;trackMonIterativeTracking2012&quot;): print &quot;trackMonIterativeTracking2012 D...
virtual unsigned L1MuPseudoSignedPacking::packedFromIdx ( int  idx,
int  sig 
) const
inlinevirtual

get the packed notation of a value, check range; sets the sign separately, 1 is neg. sign(!)

Definition at line 156 of file L1MuPacking.h.

References abs, and m_nbits.

156  {
157  unsigned packed = abs(idx);
158  unsigned maxabs = (1 << (m_nbits-1)) -1;
159  if (packed > maxabs) edm::LogWarning("ScaleRangeViolation")
160  << "L1MuPseudoSignedPacking::packedFromIdx: warning value " << idx
161  << "exceeds " << m_nbits << "-bit range !!!";
162  if (sig==1) packed |= 1 << (m_nbits-1); // sig==1 is negative
163  return packed;
164  }
#define abs(x)
Definition: mlp_lapack.h:159
tuple idx
DEBUGGING if hasattr(process,&quot;trackMonIterativeTracking2012&quot;): print &quot;trackMonIterativeTracking2012 D...
virtual int L1MuPseudoSignedPacking::signFromPacked ( unsigned  packed) const
inlinevirtual

get the (pseudo-)sign from the packed notation (0=positive, 1=negative)

Implements L1MuPacking.

Definition at line 135 of file L1MuPacking.h.

References m_nbits.

Referenced by L1MuSymmetricBinnedScale::getCenter(), and L1MuSymmetricBinnedScale::getLowEdge().

135 { return ( packed & (1 << (m_nbits-1)) ) ? 1 : 0;};

Member Data Documentation

unsigned int L1MuPseudoSignedPacking::m_nbits
private

Definition at line 167 of file L1MuPacking.h.

Referenced by idxFromPacked(), packedFromIdx(), and signFromPacked().