DD4hep
1.30.0
Detector Description Toolkit for High Energy Physics
|
Helper class for decoding and encoding a bit field of 64bits for convenient declaration. More...
#include <BitFieldCoder.h>
Public Types | |
typedef std::map< std::string, unsigned int > | IndexMap |
Public Member Functions | |
BitFieldCoder ()=default | |
Default constructor. More... | |
BitFieldCoder (const BitFieldCoder &)=default | |
Copy constructor. More... | |
BitFieldCoder (BitFieldCoder &&)=default | |
Move constructor. More... | |
~BitFieldCoder ()=default | |
Default destructor. More... | |
BitFieldCoder & | operator= (const BitFieldCoder &)=default |
Assignment operator. More... | |
BitFieldCoder (const std::string &initString) | |
FieldID | get (CellID bitfield, size_t idx) const |
FieldID | get (CellID bitfield, const std::string &name) const |
void | set (CellID &bitfield, size_t idx, FieldID value) const |
void | set (CellID &bitfield, const std::string &name, FieldID value) const |
unsigned | highestBit () const |
size_t | size () const |
size_t | index (const std::string &name) const |
const BitFieldElement & | operator[] (const std::string &name) const |
const BitFieldElement & | operator[] (unsigned idx) const |
std::string | fieldDescription () const |
std::string | valueString (CellID bitfield) const |
const std::vector< BitFieldElement > & | fields () const |
CellID | mask () const |
Static Public Member Functions | |
static CellID | toLong (unsigned low_Word, unsigned high_Word) |
static unsigned | lowWord (CellID bitfield) |
static unsigned | highWord (CellID bitfield) |
Protected Member Functions | |
void | addField (const std::string &name, unsigned offset, int width) |
void | init (const std::string &initString) |
Protected Attributes | |
std::vector< BitFieldElement > | _fields {} |
IndexMap | _map {} |
CellID | _joined {} |
Helper class for decoding and encoding a bit field of 64bits for convenient declaration.
and manipulation of sub fields of various widths.
This is a thread safe re-implementation of the functionality in the deprected BitField64.
Example:
BitFieldCoder bc("layer:7,system:-3,barrel:3,theta:32:11,phi:11" ) ;
bc.set( field, "layer" , 123 );
bc.set( field, "system" , -4 );
bc.set( field, "barrel" , 7 );
bc.set( field, "theta" , 180 );
bc.set( field, "phi" , 270 );
...
int theta = bc.get( field, "theta" ) ;
...
unsigned phiIndex = bc.index("phi") ;
int phi = bc.get( field, phiIndex ) ;
Definition at line 114 of file BitFieldCoder.h.
typedef std::map<std::string, unsigned int> dd4hep::DDSegmentation::BitFieldCoder::IndexMap |
Definition at line 116 of file BitFieldCoder.h.
|
default |
Default constructor.
|
default |
Copy constructor.
|
default |
Move constructor.
|
default |
Default destructor.
|
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 145 of file BitFieldCoder.h.
|
protected |
Add an additional field to the list
Definition at line 144 of file BitFieldCoder.cpp.
std::string dd4hep::DDSegmentation::BitFieldCoder::fieldDescription | ( | ) | const |
Return a valid description string of all fields
Definition at line 123 of file BitFieldCoder.cpp.
|
inline |
Definition at line 218 of file BitFieldCoder.h.
|
inline |
Access to field through name .
Definition at line 171 of file BitFieldCoder.h.
get value of sub-field specified by index
Definition at line 165 of file BitFieldCoder.h.
unsigned dd4hep::DDSegmentation::BitFieldCoder::highestBit | ( | ) | const |
Highest bit used in fields [0-63]
Definition at line 96 of file BitFieldCoder.cpp.
|
inlinestatic |
The high word, bits 32-63
Definition at line 161 of file BitFieldCoder.h.
size_t dd4hep::DDSegmentation::BitFieldCoder::index | ( | const std::string & | name | ) | const |
Index for field named 'name'
Definition at line 84 of file BitFieldCoder.cpp.
|
protected |
Decode the initialization string as described in the constructor.
Definition at line 166 of file BitFieldCoder.cpp.
|
inlinestatic |
The low word, bits 0-31
Definition at line 157 of file BitFieldCoder.h.
|
inline |
the mask of all the bits used in the description
Definition at line 223 of file BitFieldCoder.h.
|
default |
Assignment operator.
|
inline |
Const Access to field through name .
Definition at line 200 of file BitFieldCoder.h.
|
inline |
Const Access to field through index .
Definition at line 206 of file BitFieldCoder.h.
|
inline |
Access to field through name .
Definition at line 183 of file BitFieldCoder.h.
|
inline |
set value of sub-field specified by index
Definition at line 177 of file BitFieldCoder.h.
|
inline |
Number of values
Definition at line 192 of file BitFieldCoder.h.
|
inlinestatic |
return a new 64bit value given as high and low 32bit words.
Definition at line 151 of file BitFieldCoder.h.
std::string dd4hep::DDSegmentation::BitFieldCoder::valueString | ( | CellID | bitfield | ) | const |
Return a string with a comma separated list of the current sub field values
Definition at line 109 of file BitFieldCoder.cpp.
|
protected |
Definition at line 238 of file BitFieldCoder.h.
|
protected |
Definition at line 240 of file BitFieldCoder.h.
|
protected |
Definition at line 239 of file BitFieldCoder.h.