LDMX Software
Public Types | Public Member Functions | Static Public Member Functions | Private Attributes | List of all members
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 fieldName_
 The name of the field.
 
unsigned index_
 The index of the field.
 
unsigned startBit_
 The start bit of the field.
 
unsigned endBit_
 The end bit of the field.
 
unsigned bitMask_
 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

typedef std::vector<IDField*> ldmx::IDField::IDFieldList

List of fields.

Definition at line 25 of file IDField.h.

◆ IDFieldMap

typedef 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 : fieldName_(fieldName),
8 index_(index),
9 startBit_(startBit),
10 endBit_(endBit) {
11 // Create bit mask for the field.
12 bitMask_ = IDField::createBitMask(startBit, endBit);
13}
unsigned endBit_
The end bit of the field.
Definition IDField.h:99
unsigned startBit_
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 bitMask_
The bit mask of the field.
Definition IDField.h:104
std::string fieldName_
The name of the field.
Definition IDField.h:84
unsigned index_
The index of the field.
Definition IDField.h:89

References bitMask_, 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 bitMask_; }

References bitMask_.

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 endBit_; }

References endBit_.

◆ 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 fieldName_; }

References fieldName_.

◆ 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 startBit_; }

References startBit_.

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

Member Data Documentation

◆ bitMask_

unsigned ldmx::IDField::bitMask_
private

The bit mask of the field.

Definition at line 104 of file IDField.h.

Referenced by getBitMask(), and IDField().

◆ endBit_

unsigned ldmx::IDField::endBit_
private

The end bit of the field.

Definition at line 99 of file IDField.h.

Referenced by getEndBit().

◆ fieldName_

std::string ldmx::IDField::fieldName_
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().

◆ startBit_

unsigned ldmx::IDField::startBit_
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: