CMS 3D CMS Logo

List of all members | Public Member Functions | Private Member Functions | Private Attributes | Friends
L1MuPseudoSignedPacking Class Reference

#include <L1MuPacking.h>

Inheritance diagram for L1MuPseudoSignedPacking:
L1MuPacking

Public Member Functions

int idxFromPacked (unsigned packed) const override
 get the value from the packed notation (+/-) More...
 
 L1MuPseudoSignedPacking ()
 
 L1MuPseudoSignedPacking (unsigned int nbits)
 
unsigned packedFromIdx (int idx) const override
 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...
 
int signFromPacked (unsigned packed) const override
 get the (pseudo-)sign from the packed notation (0=positive, 1=negative) More...
 
 ~L1MuPseudoSignedPacking () override
 
- Public Member Functions inherited from L1MuPacking
virtual ~L1MuPacking ()
 

Private Member Functions

template<class Archive >
void serialize (Archive &ar, const unsigned int version)
 

Private Attributes

unsigned int m_nbits
 

Friends

class boost::serialization::access
 
template<typename CondSerializationT , typename Enabled >
struct cond::serialization::access
 

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 140 of file L1MuPacking.h.

Constructor & Destructor Documentation

◆ L1MuPseudoSignedPacking() [1/2]

L1MuPseudoSignedPacking::L1MuPseudoSignedPacking ( )
inline

Definition at line 142 of file L1MuPacking.h.

142 {}

◆ ~L1MuPseudoSignedPacking()

L1MuPseudoSignedPacking::~L1MuPseudoSignedPacking ( )
inlineoverride

Definition at line 143 of file L1MuPacking.h.

143 {};

◆ L1MuPseudoSignedPacking() [2/2]

L1MuPseudoSignedPacking::L1MuPseudoSignedPacking ( unsigned int  nbits)
inline

Definition at line 144 of file L1MuPacking.h.

144 : m_nbits(nbits){};

Member Function Documentation

◆ idxFromPacked()

int L1MuPseudoSignedPacking::idxFromPacked ( unsigned  packed) const
inlineoverridevirtual

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

Implements L1MuPacking.

Definition at line 150 of file L1MuPacking.h.

150  {
151  unsigned mask = (1 << (m_nbits - 1)) - 1; // for lower bits
152  int absidx = (int)(packed & mask);
153  unsigned psmask = (1 << (m_nbits - 1));
154  return absidx * (((packed & psmask) == psmask) ? -1 : 1); // pseudo sign==1 is negative
155  };

References createfilelist::int, and m_nbits.

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

◆ packedFromIdx() [1/2]

unsigned L1MuPseudoSignedPacking::packedFromIdx ( int  idx) const
inlineoverridevirtual

get the packed notation of a value, check range

Implements L1MuPacking.

Definition at line 157 of file L1MuPacking.h.

157  {
158  unsigned packed = std::abs(idx);
159  unsigned maxabs = (1 << (m_nbits - 1)) - 1;
160  if (packed > maxabs)
161  edm::LogWarning("ScaleRangeViolation") << "L1MuPseudoSignedPacking::packedFromIdx: warning value " << idx
162  << "exceeds " << m_nbits << "-bit range !!!";
163  if (idx < 0)
164  packed |= 1 << (m_nbits - 1);
165  return packed;
166  }

References funct::abs(), heavyIonCSV_trainingSettings::idx, and m_nbits.

Referenced by L1MuSymmetricBinnedScale::getPacked().

◆ packedFromIdx() [2/2]

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 169 of file L1MuPacking.h.

169  {
170  unsigned packed = std::abs(idx);
171  unsigned maxabs = (1 << (m_nbits - 1)) - 1;
172  if (packed > maxabs)
173  edm::LogWarning("ScaleRangeViolation") << "L1MuPseudoSignedPacking::packedFromIdx: warning value " << idx
174  << "exceeds " << m_nbits << "-bit range !!!";
175  if (sig == 1)
176  packed |= 1 << (m_nbits - 1); // sig==1 is negative
177  return packed;
178  }

References funct::abs(), heavyIonCSV_trainingSettings::idx, and m_nbits.

◆ serialize()

template<class Archive >
void L1MuPseudoSignedPacking::serialize ( Archive &  ar,
const unsigned int  version 
)
private

◆ signFromPacked()

int L1MuPseudoSignedPacking::signFromPacked ( unsigned  packed) const
inlineoverridevirtual

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

Implements L1MuPacking.

Definition at line 147 of file L1MuPacking.h.

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

References m_nbits.

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

Friends And Related Function Documentation

◆ boost::serialization::access

friend class boost::serialization::access
friend

Definition at line 183 of file L1MuPacking.h.

◆ cond::serialization::access

template<typename CondSerializationT , typename Enabled >
friend struct cond::serialization::access
friend

Definition at line 183 of file L1MuPacking.h.

Member Data Documentation

◆ m_nbits

unsigned int L1MuPseudoSignedPacking::m_nbits
private

Definition at line 181 of file L1MuPacking.h.

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

edm::LogWarning
Log< level::Warning, false > LogWarning
Definition: MessageLogger.h:122
heavyIonCSV_trainingSettings.idx
idx
Definition: heavyIonCSV_trainingSettings.py:5
createfilelist.int
int
Definition: createfilelist.py:10
L1MuPseudoSignedPacking::m_nbits
unsigned int m_nbits
Definition: L1MuPacking.h:181
funct::abs
Abs< T >::type abs(const T &t)
Definition: Abs.h:22