LDMX Software
ldmx::IDField Class Reference

Provides information about a field within a DetectorID. More...

#include <IDField.h>

Public Types

typedef std::map< std::string, IDField * > IDFieldMap
 Map of name to field.
 
typedef std::vector< IDField * > IDFieldList
 List of fields.
 

Public Member Functions

 IDField (std::string name, unsigned index, unsigned startBit, unsigned endBit)
 Class constructor.
 
const std::string & getFieldName ()
 Get the name of the field.
 
unsigned getIndex ()
 Get the index of the field.
 
unsigned getStartBit ()
 Get the start bit of the field.
 
unsigned getEndBit ()
 Get the end bit of the field.
 
unsigned getBitMask ()
 Get a bit mask for this field.
 

Static Public Member Functions

static unsigned createBitMask (unsigned startBit, unsigned endBit)
 Utility for creating a bit mask from a start to end bit.
 
static unsigned countOnes (unsigned mask)
 Utility for counting number of 1 in a mask.
 

Private Attributes

std::string field_name_
 The name of the field.
 
unsigned index_
 The index of the field.
 
unsigned start_bit_
 The start bit of the field.
 
unsigned end_bit_
 The end bit of the field.
 
unsigned bit_mask_
 The bit mask of the field.
 

Detailed Description

Provides information about a field within a DetectorID.

Definition at line 15 of file IDField.h.

Member Typedef Documentation

◆ IDFieldList

List of fields.

Definition at line 25 of file IDField.h.

◆ IDFieldMap

std::map<std::string, IDField*> ldmx::IDField::IDFieldMap

Map of name to field.

Definition at line 20 of file IDField.h.

Constructor & Destructor Documentation

◆ IDField()

ldmx::IDField::IDField ( std::string name,
unsigned index,
unsigned startBit,
unsigned endBit )

Class constructor.

Parameters
nameThe name of the field.
indexThe index of the field in the ID.
startBitThe start bit of the field.
endBitThe end bit of the field.

Definition at line 5 of file IDField.cxx.

7 : field_name_(fieldName),
8 index_(index),
9 start_bit_(startBit),
10 end_bit_(endBit) {
11 // Create bit mask for the field.
12 bit_mask_ = IDField::createBitMask(startBit, endBit);
13}
unsigned bit_mask_
The bit mask of the field.
Definition IDField.h:104
unsigned start_bit_
The start bit of the field.
Definition IDField.h:94
static unsigned createBitMask(unsigned startBit, unsigned endBit)
Utility for creating a bit mask from a start to end bit.
Definition IDField.cxx:25
unsigned end_bit_
The end bit of the field.
Definition IDField.h:99
unsigned index_
The index of the field.
Definition IDField.h:89
std::string field_name_
The name of the field.
Definition IDField.h:84

References bit_mask_, and createBitMask().

Member Function Documentation

◆ countOnes()

unsigned ldmx::IDField::countOnes ( unsigned mask)
static

Utility for counting number of 1 in a mask.

Parameters
startBitThe start bit.
endBitThe end bit.

Definition at line 33 of file IDField.cxx.

33 {
34 unsigned rv = 0;
35 for (int i = 0; i < 32; i++)
36 if (mask & (1 << i)) rv++;
37 return rv;
38}

◆ createBitMask()

unsigned ldmx::IDField::createBitMask ( unsigned startBit,
unsigned endBit )
static

Utility for creating a bit mask from a start to end bit.

Parameters
startBitThe start bit.
endBitThe end bit.

Definition at line 25 of file IDField.cxx.

25 {
26 unsigned mask = 0;
27 for (int i = startBit; i <= endBit; i++) {
28 mask |= 1 << i;
29 }
30 return mask;
31}

Referenced by IDField().

◆ getBitMask()

unsigned ldmx::IDField::getBitMask ( )

Get a bit mask for this field.

Returns
A bit mask for this field.

Definition at line 23 of file IDField.cxx.

23{ return bit_mask_; }

References bit_mask_.

Referenced by ldmx::DetectorIDInterpreter::getFieldValue().

◆ getEndBit()

unsigned ldmx::IDField::getEndBit ( )

Get the end bit of the field.

Returns
The end bit of the field.

Definition at line 21 of file IDField.cxx.

21{ return end_bit_; }

References end_bit_.

◆ getFieldName()

const std::string & ldmx::IDField::getFieldName ( )

Get the name of the field.

Returns
The name of the field.

Definition at line 15 of file IDField.cxx.

15{ return field_name_; }

References field_name_.

◆ getIndex()

unsigned ldmx::IDField::getIndex ( )

Get the index of the field.

Returns
The index of the field.

Definition at line 17 of file IDField.cxx.

17{ return index_; }

References index_.

◆ getStartBit()

unsigned ldmx::IDField::getStartBit ( )

Get the start bit of the field.

Returns
The start bit of the field.

Definition at line 19 of file IDField.cxx.

19{ return start_bit_; }

References start_bit_.

Referenced by ldmx::DetectorIDInterpreter::getFieldValue().

Member Data Documentation

◆ bit_mask_

unsigned ldmx::IDField::bit_mask_
private

The bit mask of the field.

Definition at line 104 of file IDField.h.

Referenced by getBitMask(), and IDField().

◆ end_bit_

unsigned ldmx::IDField::end_bit_
private

The end bit of the field.

Definition at line 99 of file IDField.h.

Referenced by getEndBit().

◆ field_name_

std::string ldmx::IDField::field_name_
private

The name of the field.

Definition at line 84 of file IDField.h.

Referenced by getFieldName().

◆ index_

unsigned ldmx::IDField::index_
private

The index of the field.

Definition at line 89 of file IDField.h.

Referenced by getIndex().

◆ start_bit_

unsigned ldmx::IDField::start_bit_
private

The start bit of the field.

Definition at line 94 of file IDField.h.

Referenced by getStartBit().


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