ATLAS Offline Software
Public Member Functions | Protected Attributes | List of all members
CaloCellPackerUtils::Bitfield Class Reference

Helper for packing into/out of a bit field. More...

#include <CaloCellPackerUtils.h>

Inheritance diagram for CaloCellPackerUtils::Bitfield:
Collaboration diagram for CaloCellPackerUtils::Bitfield:

Public Member Functions

 Bitfield (unsigned int mask=1)
 Constructor. More...
 
unsigned int in (unsigned int x) const
 Shift and mask a value into the bitfield. More...
 
unsigned int out (unsigned int x) const
 Extract a value from the bitfield. More...
 

Protected Attributes

unsigned int m_mask
 Bitmask. Lower bit should be 1. More...
 
unsigned int m_shift
 Shift count. More...
 

Detailed Description

Helper for packing into/out of a bit field.

The bitfield is identified by a bitmask, which should contain a contiguous string of 1's. The in function will then take a value and shift and mask it appropriately for the bitfield. The out function will extract a value from the bitfield.

Definition at line 36 of file CaloCellPackerUtils.h.

Constructor & Destructor Documentation

◆ Bitfield()

CaloCellPackerUtils::Bitfield::Bitfield ( unsigned int  mask = 1)

Constructor.

Parameters
Thebit mask. Should contain a single contiguous string of 1's.

Definition at line 25 of file CaloCellPackerUtils.cxx.

26 {
27  // Shift the mask until the rightmost bit is non-zero.
28  assert (mask != 0);
29  m_shift = 0;
30  while ((mask & 1) == 0) {
31  mask >>= 1;
32  ++m_shift;
33  }
34  m_mask = mask;
35 }

Member Function Documentation

◆ in()

unsigned int CaloCellPackerUtils::Bitfield::in ( unsigned int  x) const

Shift and mask a value into the bitfield.

Parameters
xThe input value.
Returns
The value shifted and masked to go into the bitfield.

◆ out()

unsigned int CaloCellPackerUtils::Bitfield::out ( unsigned int  x) const

Extract a value from the bitfield.

Parameters
xThe input bitfield.
Returns
The value extracted from the bitfield.

Member Data Documentation

◆ m_mask

unsigned int CaloCellPackerUtils::Bitfield::m_mask
protected

Bitmask. Lower bit should be 1.

Definition at line 64 of file CaloCellPackerUtils.h.

◆ m_shift

unsigned int CaloCellPackerUtils::Bitfield::m_shift
protected

Shift count.

Definition at line 67 of file CaloCellPackerUtils.h.


The documentation for this class was generated from the following files:
CaloCellPackerUtils::Bitfield::m_shift
unsigned int m_shift
Shift count.
Definition: CaloCellPackerUtils.h:67
python.utils.AtlRunQueryLookup.mask
string mask
Definition: AtlRunQueryLookup.py:460
CaloCellPackerUtils::Bitfield::m_mask
unsigned int m_mask
Bitmask. Lower bit should be 1.
Definition: CaloCellPackerUtils.h:64