DD4hep  1.28.0
Detector Description Toolkit for High Energy Physics
Public Member Functions | Protected Attributes | Friends | List of all members
dd4hep::DDSegmentation::BitField64 Class Reference

A bit field of 64bits that allows convenient declaration. More...

#include <BitField64.h>

Public Member Functions

virtual ~BitField64 ()
 
 BitField64 ()=delete
 
 BitField64 (const std::string &initString)
 
 BitField64 (const BitFieldCoder *coder)
 Initialize from existing BitFieldCoder. More...
 
CellID getValue () const
 
void setValue (CellID value)
 
void setValue (unsigned low_Word, unsigned high_Word)
 
BitField64operator() (CellID val)
 
void reset ()
 
BitFieldValue operator[] (size_t idx)
 
unsigned highestBit () const
 
size_t size () const
 
size_t index (const std::string &name) const
 
BitFieldValue operator[] (const std::string &name)
 
unsigned lowWord () const
 
unsigned highWord () const
 
std::string fieldDescription () const
 
std::string valueString () const
 

Protected Attributes

bool _owner {true}
 
CellID _value {}
 
const BitFieldCoder_coder {}
 

Friends

std::ostream & operator<< (std::ostream &os, const BitField64 &b)
 

Detailed Description

A bit field of 64bits that allows convenient declaration.

and manipulation of sub fields of various widths.
Example:
BitField64 b("layer:7,system:-3,barrel:3,theta:32:11,phi:11" ) ;
b[ "layer" ] = 123 ;
b[ "system" ] = -4 ;
b[ "barrel" ] = 7 ;
b[ "theta" ] = 180 ;
b[ "phi" ] = 270 ;
...
int theta = b["theta"] ;
...
unsigned phiIndex = b.index("phi") ;
int phi = b[ phiIndex ] ;

Sep-2017: FG: re-implemented as lightweight wrapper around BitFieldCoder

Author
F.Gaede, DESY
Date
2013-06

Definition at line 110 of file BitField64.h.

Constructor & Destructor Documentation

◆ ~BitField64()

virtual dd4hep::DDSegmentation::BitField64::~BitField64 ( )
inlinevirtual

Definition at line 116 of file BitField64.h.

◆ BitField64() [1/3]

dd4hep::DDSegmentation::BitField64::BitField64 ( )
delete

No default c'tor

◆ BitField64() [2/3]

dd4hep::DDSegmentation::BitField64::BitField64 ( const std::string &  initString)
inline

The c'tor takes an initialization string of the form:
<fieldDesc>[,<fieldDesc>...]
fieldDesc = name:[start]:[-]length
where:
name: The name of the field
start: The start bit of the field. If omitted assumed to start immediately following previous field, or at the least significant bit if the first field.
length: The number of bits in the field. If preceeded by '-' the field is signed, otherwise unsigned.
Bit numbering is from the least significant bit (bit 0) to the most significant (bit 63).
Example: "layer:7,system:-3,barrel:3,theta:32:11,phi:11"

Definition at line 138 of file BitField64.h.

◆ BitField64() [3/3]

dd4hep::DDSegmentation::BitField64::BitField64 ( const BitFieldCoder coder)
inline

Initialize from existing BitFieldCoder.

Definition at line 143 of file BitField64.h.

Member Function Documentation

◆ fieldDescription()

std::string dd4hep::DDSegmentation::BitField64::fieldDescription ( ) const
inline

Return a valid description string of all fields

Definition at line 216 of file BitField64.h.

◆ getValue()

CellID dd4hep::DDSegmentation::BitField64::getValue ( ) const
inline

Returns the current 64bit value

Definition at line 149 of file BitField64.h.

◆ highestBit()

unsigned dd4hep::DDSegmentation::BitField64::highestBit ( ) const
inline

Highest bit used in fields [0-63]

Definition at line 183 of file BitField64.h.

◆ highWord()

unsigned dd4hep::DDSegmentation::BitField64::highWord ( ) const
inline

The high word, bits 32-63

Definition at line 211 of file BitField64.h.

◆ index()

size_t dd4hep::DDSegmentation::BitField64::index ( const std::string &  name) const
inline

Index for field named 'name'

Definition at line 190 of file BitField64.h.

◆ lowWord()

unsigned dd4hep::DDSegmentation::BitField64::lowWord ( ) const
inline

The low word, bits 0-31

Definition at line 207 of file BitField64.h.

◆ operator()()

BitField64& dd4hep::DDSegmentation::BitField64::operator() ( CellID  val)
inline

Operator for setting a new value and accessing the BitField directly

Definition at line 162 of file BitField64.h.

◆ operator[]() [1/2]

BitFieldValue dd4hep::DDSegmentation::BitField64::operator[] ( const std::string &  name)
inline

Access to field through name .

Definition at line 194 of file BitField64.h.

◆ operator[]() [2/2]

BitFieldValue dd4hep::DDSegmentation::BitField64::operator[] ( size_t  idx)
inline

Acces to field through index

Definition at line 170 of file BitField64.h.

◆ reset()

void dd4hep::DDSegmentation::BitField64::reset ( )
inline

Reset - same as setValue(0) - useful if the same encoder is used for many objects.

Definition at line 166 of file BitField64.h.

◆ setValue() [1/2]

void dd4hep::DDSegmentation::BitField64::setValue ( CellID  value)
inline

Set a new 64bit value - bits not used in description are set to 0.

Definition at line 153 of file BitField64.h.

◆ setValue() [2/2]

void dd4hep::DDSegmentation::BitField64::setValue ( unsigned  low_Word,
unsigned  high_Word 
)
inline

Set a new 64bit value given as high and low 32bit words.

Definition at line 157 of file BitField64.h.

◆ size()

size_t dd4hep::DDSegmentation::BitField64::size ( ) const
inline

Number of values

Definition at line 186 of file BitField64.h.

◆ valueString()

std::string dd4hep::DDSegmentation::BitField64::valueString ( ) const

Return a string with a comma separated list of the current sub field values

Definition at line 12 of file BitField64.cpp.

Friends And Related Function Documentation

◆ operator<<

std::ostream& operator<< ( std::ostream &  os,
const BitField64 b 
)
friend

Operator for dumping BitField64 to streams

Definition at line 27 of file BitField64.cpp.

Member Data Documentation

◆ _coder

const BitFieldCoder* dd4hep::DDSegmentation::BitField64::_coder {}
protected

Definition at line 231 of file BitField64.h.

◆ _owner

bool dd4hep::DDSegmentation::BitField64::_owner {true}
protected

Definition at line 229 of file BitField64.h.

◆ _value

CellID dd4hep::DDSegmentation::BitField64::_value {}
protected

Definition at line 230 of file BitField64.h.


The documentation for this class was generated from the following files: