CMS 3D CMS Logo

Public Member Functions | Private Attributes

L1MuPseudoSignedPacking Class Reference

#include <L1MuPacking.h>

Inheritance diagram for L1MuPseudoSignedPacking:
L1MuPacking

List of all members.

Public Member Functions

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

{}
virtual L1MuPseudoSignedPacking::~L1MuPseudoSignedPacking ( ) [inline, virtual]

Definition at line 131 of file L1MuPacking.h.

{};
L1MuPseudoSignedPacking::L1MuPseudoSignedPacking ( unsigned int  nbits) [inline]

Definition at line 132 of file L1MuPacking.h.

: m_nbits(nbits) {};

Member Function Documentation

virtual int L1MuPseudoSignedPacking::idxFromPacked ( unsigned  packed) const [inline, virtual]

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().

                                                   {
    unsigned mask = (1 << (m_nbits-1)) - 1; // for lower bits
    int absidx = (int) ( packed & mask );
    unsigned psmask = (1 << (m_nbits-1) );
    return absidx * ( ( (packed & psmask) == psmask ) ? -1 : 1 ); // pseudo sign==1 is negative
  };  
virtual unsigned L1MuPseudoSignedPacking::packedFromIdx ( int  idx,
int  sig 
) const [inline, virtual]

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.

                                                         {
    unsigned packed = abs(idx);
    unsigned maxabs = (1 << (m_nbits-1)) -1;
    if (packed > maxabs) edm::LogWarning("ScaleRangeViolation") 
                              << "L1MuPseudoSignedPacking::packedFromIdx: warning value " << idx 
                              << "exceeds " << m_nbits << "-bit range !!!";
    if (sig==1) packed |= 1 << (m_nbits-1); // sig==1 is negative
    return  packed;
  }
virtual unsigned L1MuPseudoSignedPacking::packedFromIdx ( int  idx) const [inline, virtual]

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().

                                                {
    unsigned packed = abs(idx);
    unsigned maxabs = (1 << (m_nbits-1)) -1;
    if (packed > maxabs) edm::LogWarning("ScaleRangeViolation") 
                              << "L1MuPseudoSignedPacking::packedFromIdx: warning value " << idx 
                              << "exceeds " << m_nbits << "-bit range !!!";
    if (idx < 0) packed |= 1 << (m_nbits-1);
    return  packed;
  }
virtual int L1MuPseudoSignedPacking::signFromPacked ( unsigned  packed) const [inline, virtual]

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().

{ 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().