ATLAS Offline Software
Public Types | Public Member Functions | Private Member Functions | Private Attributes | List of all members
IdDictFieldImplementation Class Reference

IdDictFieldImplementation is used to capture the specification of a single field of an Identifier. More...

#include <IdDictFieldImplementation.h>

Collaboration diagram for IdDictFieldImplementation:

Public Types

enum  bit_defs { NBITS = sizeof(value_type) * 8, MAX_BIT = (static_cast<value_type>(1) << (NBITS - 1)), ALL_BITS = ~(static_cast<value_type>(0)) }
 
typedef Identifier::value_type value_type
 
typedef Identifier::size_type size_type
 

Public Member Functions

 IdDictFieldImplementation ()
 
int unpack (Identifier id) const
 Identifier manipulation methods. More...
 
size_type unpackToIndex (Identifier id) const
 Unpack a single field index of the id. More...
 
void pack (int value, Identifier &id) const
 
void reset (Identifier &id) const
 
const IdDictRangerange () const
 Accessors. More...
 
const Range::fieldfield () const
 
const Range::fieldored_field () const
 
size_type bits () const
 
size_type bits_offset () const
 
size_type mask () const
 
value_type zeroing_mask () const
 
size_type shift () const
 
bool decode_index () const
 
void set_range (const IdDictRange *range)
 Modifiers. More...
 
void set_field (const Range::field &field)
 
void set_ored_field (const Range::field &ored_field)
 
void set_bits_offset (size_type bits_offset)
 
void set_bits (size_type bits, size_type bits_offset)
 
void set_decode_index (bool decode_index)
 
void optimize (void)
 
void show (void) const
 
std::string show_to_string (void) const
 

Private Member Functions

void initialize ()
 

Private Attributes

const IdDictRangem_range
 
Range::field m_field
 
Range::field m_ored_field
 
size_type m_bits
 
size_type m_bits_offset
 
size_type m_mask
 
value_type m_zeroing_mask
 
size_type m_shift
 
bool m_decode_index
 

Detailed Description

IdDictFieldImplementation is used to capture the specification of a single field of an Identifier.

This class is primarily used to extract or set the field of an identifier:

int unpack (Identifier id) const; // access to field value size_type unpackToIndex (Identifier id) const; // access to field index, i.e. from 0 void pack (int value, Identifier& id) const; void reset (Identifier& id) const; // reset field bits

This class is normally filled during the parsing of the identifier dictionary. The parsing uses the set_ored_field method where the the internal variables are set to optimize the calculations. One may also build a new object by simply using:

void set_bits (size_type bits, size_type bits_offset);

This as well sets all internal variables.

The meaning of the varibles is:

size_type bits() - number of bits for this field size_type bits_offset() - bits offset relative to 1st field size_type mask() - mask: (xxx >> shift) & mask value_type zeroing_mask() - used to reset field to 0 size_type shift() - shift: (xxx >> shift) & mask bool decode_index() - true == need to lookup value

// Primarily for internal use: const IdDictRange* range() - points to the generating IdDictRange Range::field field() - derived from IdDictRange Range::field ored_field() - "expanded" field to account for other overlapping fields

Definition at line 57 of file IdDictFieldImplementation.h.

Member Typedef Documentation

◆ size_type

Definition at line 62 of file IdDictFieldImplementation.h.

◆ value_type

Definition at line 61 of file IdDictFieldImplementation.h.

Member Enumeration Documentation

◆ bit_defs

Enumerator
NBITS 
MAX_BIT 
ALL_BITS 

Definition at line 64 of file IdDictFieldImplementation.h.

65  {
66  NBITS = sizeof(value_type) * 8, // bits per byte
67  MAX_BIT = (static_cast<value_type>(1) << (NBITS - 1)),
68  ALL_BITS = ~(static_cast<value_type>(0))
69  } bit_defs;

Constructor & Destructor Documentation

◆ IdDictFieldImplementation()

IdDictFieldImplementation::IdDictFieldImplementation ( )
inline

Definition at line 124 of file IdDictFieldImplementation.h.

126  :
127  m_range(0),
128  m_field(0),
129  m_ored_field(0),
130  m_bits(0),
131  m_bits_offset(0),
132  m_mask(0),
133  m_zeroing_mask(0),
134  m_shift(0),
135  m_decode_index(0)
136 {}

Member Function Documentation

◆ bits()

IdDictFieldImplementation::size_type IdDictFieldImplementation::bits ( ) const
inline

Definition at line 202 of file IdDictFieldImplementation.h.

204 { return (m_bits); }

◆ bits_offset()

IdDictFieldImplementation::size_type IdDictFieldImplementation::bits_offset ( ) const
inline

Definition at line 208 of file IdDictFieldImplementation.h.

210 { return (m_bits_offset); }

◆ decode_index()

bool IdDictFieldImplementation::decode_index ( ) const
inline

Definition at line 231 of file IdDictFieldImplementation.h.

233 { return (m_decode_index); }

◆ field()

const Range::field & IdDictFieldImplementation::field ( ) const
inline

Definition at line 191 of file IdDictFieldImplementation.h.

193 { return (m_field); }

◆ initialize()

void IdDictFieldImplementation::initialize ( )
inlineprivate

Definition at line 236 of file IdDictFieldImplementation.h.

238 {
239  // Initialize masks and shift
240  m_mask = (static_cast<size_type>(1) << m_bits) - 1;
242 
243  // Shifting by NBITS is undefined behavior.
246  else
248 }

◆ mask()

IdDictFieldImplementation::size_type IdDictFieldImplementation::mask ( ) const
inline

Definition at line 214 of file IdDictFieldImplementation.h.

216 { return (m_mask); }

◆ optimize()

void IdDictFieldImplementation::optimize ( void  )
inline

Definition at line 294 of file IdDictFieldImplementation.h.

295 {
296  m_ored_field.optimize(); // optimize for decoding
297 }

◆ ored_field()

const Range::field & IdDictFieldImplementation::ored_field ( ) const
inline

Definition at line 196 of file IdDictFieldImplementation.h.

198 { return (m_ored_field); }

◆ pack()

void IdDictFieldImplementation::pack ( int  value,
Identifier id 
) const
inline

Definition at line 173 of file IdDictFieldImplementation.h.

175 {
176  // Pack value into this field
179  id |= (index << m_shift);
180 }

◆ range()

const IdDictRange * IdDictFieldImplementation::range ( ) const

Accessors.

Definition at line 25 of file IdDictFieldImplementation.cxx.

25 {return(m_range);}

◆ reset()

void IdDictFieldImplementation::reset ( Identifier id) const
inline

Definition at line 183 of file IdDictFieldImplementation.h.

185 {
186  // Reset field to 0
187  id &= m_zeroing_mask;
188 }

◆ set_bits()

void IdDictFieldImplementation::set_bits ( size_type  bits,
size_type  bits_offset 
)
inline

Definition at line 278 of file IdDictFieldImplementation.h.

280 {
281  // Set bits, offset and init
282  m_bits = bits;
284  initialize();
285 }

◆ set_bits_offset()

void IdDictFieldImplementation::set_bits_offset ( size_type  bits_offset)
inline

Definition at line 269 of file IdDictFieldImplementation.h.

271 {
272  // Set offset and init
274  initialize();
275 }

◆ set_decode_index()

void IdDictFieldImplementation::set_decode_index ( bool  decode_index)
inline

Definition at line 288 of file IdDictFieldImplementation.h.

290 {
292 }

◆ set_field()

void IdDictFieldImplementation::set_field ( const Range::field field)
inline

Definition at line 251 of file IdDictFieldImplementation.h.

253 {
254  m_field = field;
255 }

◆ set_ored_field()

void IdDictFieldImplementation::set_ored_field ( const Range::field ored_field)
inline

Definition at line 259 of file IdDictFieldImplementation.h.

261 {
262  // Set ored field and bits, and init
265  initialize();
266 }

◆ set_range()

void IdDictFieldImplementation::set_range ( const IdDictRange range)

Modifiers.

Definition at line 28 of file IdDictFieldImplementation.cxx.

28  {
29  m_range = range;
30 }

◆ shift()

IdDictFieldImplementation::size_type IdDictFieldImplementation::shift ( ) const
inline

Definition at line 226 of file IdDictFieldImplementation.h.

228 { return (m_shift); }

◆ show()

void IdDictFieldImplementation::show ( void  ) const

Definition at line 33 of file IdDictFieldImplementation.cxx.

33  {
34  std::cout << show_to_string() << std::endl;
35 }

◆ show_to_string()

std::string IdDictFieldImplementation::show_to_string ( void  ) const

Definition at line 38 of file IdDictFieldImplementation.cxx.

38  {
39  std::stringstream str;
40  unsigned int pos;
41  unsigned int nchar;
42  str << "decode " << m_decode_index;
43  str << " vals ";
44  pos = str.tellp();
45  // values
46  str << (std::string) m_ored_field;
47  nchar = (unsigned int) str.tellp() - pos;
48  if (nchar < 15) tabify(15 - nchar, str);
49  str << " mask/zero mask/shift/bits/offset ";
50  pos = str.tellp();
51  // mask
52  str << std::hex << m_mask << " ";
53  nchar = (unsigned int) str.tellp() - pos;
54  if (nchar < 4) tabify(4 - nchar, str);
55  // zeroing mask
56  str << m_zeroing_mask << " " << std::dec;
57  pos = str.tellp();
58  // shift
59  str << m_shift << " ";
60  nchar = (unsigned int) str.tellp() - pos;
61  if (nchar < 3) tabify(3 - nchar, str);
62  pos = str.tellp();
63  // bits
64  str << m_bits << " ";
65  nchar = (unsigned int) str.tellp() - pos;
66  if (nchar < 3) tabify(3 - nchar, str);
67  pos = str.tellp();
68  // offset
69  str << m_bits_offset << " ";
70  nchar = (unsigned int) str.tellp() - pos;
71  if (nchar < 3) tabify(3 - nchar, str);
72  str << "indexes ";
73  pos = str.tellp();
74  // indexes
75  for (size_type i = 0; i < m_ored_field.get_indexes().size(); ++i) {
76  str << m_ored_field.get_indexes()[i] << " ";
77  }
78  nchar = (unsigned int) str.tellp() - pos;
79  if (nchar < 20) tabify(20 - nchar, str);
80  str << "mode ";
81  if (m_ored_field.isBounded()) str << "both_bounded ";
82  else if (m_ored_field.isEnumerated()) str << "enumerated ";
83  else str << "unknown ";
84  return(str.str());
85 }

◆ unpack()

int IdDictFieldImplementation::unpack ( Identifier  id) const
inline

Identifier manipulation methods.

Unpack a single field of the bits32 id.

One specifies the pointer to the field implementation to be used for decoding. The first_field_index is normally 0. It is non-zero when fields 0 to first_field_index -1 are missing from the compact

Definition at line 147 of file IdDictFieldImplementation.h.

149 {
150  // Unpack field
151  size_type index = id.extract(m_shift, m_mask);
152  int field = index;
154  return (field);
155 }

◆ unpackToIndex()

Identifier::size_type IdDictFieldImplementation::unpackToIndex ( Identifier  id) const
inline

Unpack a single field index of the id.

The value unpacked above may differ from the index if the values are enumerated rather than simply 0 to N-1.

Definition at line 164 of file IdDictFieldImplementation.h.

166 {
167  // Unpack field
168  size_type index = id.extract(m_shift, m_mask);
169  return (index);
170 }

◆ zeroing_mask()

IdDictFieldImplementation::value_type IdDictFieldImplementation::zeroing_mask ( ) const
inline

Definition at line 220 of file IdDictFieldImplementation.h.

222 { return (m_zeroing_mask); }

Member Data Documentation

◆ m_bits

size_type IdDictFieldImplementation::m_bits
private

Definition at line 111 of file IdDictFieldImplementation.h.

◆ m_bits_offset

size_type IdDictFieldImplementation::m_bits_offset
private

Definition at line 112 of file IdDictFieldImplementation.h.

◆ m_decode_index

bool IdDictFieldImplementation::m_decode_index
private

Definition at line 116 of file IdDictFieldImplementation.h.

◆ m_field

Range::field IdDictFieldImplementation::m_field
private

Definition at line 109 of file IdDictFieldImplementation.h.

◆ m_mask

size_type IdDictFieldImplementation::m_mask
private

Definition at line 113 of file IdDictFieldImplementation.h.

◆ m_ored_field

Range::field IdDictFieldImplementation::m_ored_field
private

Definition at line 110 of file IdDictFieldImplementation.h.

◆ m_range

const IdDictRange* IdDictFieldImplementation::m_range
private

Definition at line 108 of file IdDictFieldImplementation.h.

◆ m_shift

size_type IdDictFieldImplementation::m_shift
private

Definition at line 115 of file IdDictFieldImplementation.h.

◆ m_zeroing_mask

value_type IdDictFieldImplementation::m_zeroing_mask
private

Definition at line 114 of file IdDictFieldImplementation.h.


The documentation for this class was generated from the following files:
IdDictFieldImplementation::bit_defs
bit_defs
Definition: IdDictFieldImplementation.h:65
IdDictFieldImplementation::value_type
Identifier::value_type value_type
Definition: IdDictFieldImplementation.h:61
IdentifierField::get_bits
size_type get_bits() const
Definition: IdentifierField.cxx:40
CaloCellPos2Ntuple.int
int
Definition: CaloCellPos2Ntuple.py:24
IdDictFieldImplementation::show_to_string
std::string show_to_string(void) const
Definition: IdDictFieldImplementation.cxx:38
IdDictFieldImplementation::initialize
void initialize()
Definition: IdDictFieldImplementation.h:236
index
Definition: index.py:1
IdDictFieldImplementation::m_field
Range::field m_field
Definition: IdDictFieldImplementation.h:109
athena.value
value
Definition: athena.py:124
IdDictFieldImplementation::decode_index
bool decode_index() const
Definition: IdDictFieldImplementation.h:231
IdDictFieldImplementation::m_decode_index
bool m_decode_index
Definition: IdDictFieldImplementation.h:116
IdDictFieldImplementation::m_range
const IdDictRange * m_range
Definition: IdDictFieldImplementation.h:108
IdDictFieldImplementation::m_bits_offset
size_type m_bits_offset
Definition: IdDictFieldImplementation.h:112
python.setupRTTAlg.size
int size
Definition: setupRTTAlg.py:39
IdDictFieldImplementation::m_mask
size_type m_mask
Definition: IdDictFieldImplementation.h:113
IdentifierField::get_indexes
const index_vector & get_indexes() const
Definition: IdentifierField.h:79
IdDictFieldImplementation::field
const Range::field & field() const
Definition: IdDictFieldImplementation.h:191
IdentifierField::get_value_index
size_type get_value_index(element_type value) const
Definition: IdentifierField.cxx:49
lumiFormat.i
int i
Definition: lumiFormat.py:85
IdDictFieldImplementation::m_zeroing_mask
value_type m_zeroing_mask
Definition: IdDictFieldImplementation.h:114
IdDictFieldImplementation::ALL_BITS
@ ALL_BITS
Definition: IdDictFieldImplementation.h:68
IdDictFieldImplementation::bits_offset
size_type bits_offset() const
Definition: IdDictFieldImplementation.h:208
IdDictFieldImplementation::ored_field
const Range::field & ored_field() const
Definition: IdDictFieldImplementation.h:196
IdentifierField::isEnumerated
bool isEnumerated() const
Definition: IdentifierField.h:117
IdDictFieldImplementation::range
const IdDictRange * range() const
Accessors.
Definition: IdDictFieldImplementation.cxx:25
IdDictFieldImplementation::m_bits
size_type m_bits
Definition: IdDictFieldImplementation.h:111
python.LumiBlobConversion.pos
pos
Definition: LumiBlobConversion.py:18
IdentifierField::isBounded
bool isBounded() const
Definition: IdentifierField.h:116
DeMoScan.index
string index
Definition: DeMoScan.py:364
python.CaloScaleNoiseConfig.str
str
Definition: CaloScaleNoiseConfig.py:78
IdentifierField::get_value_at
element_type get_value_at(size_type index) const
Definition: IdentifierField.h:141
IdDictFieldImplementation::MAX_BIT
@ MAX_BIT
Definition: IdDictFieldImplementation.h:67
IdDictFieldImplementation::NBITS
@ NBITS
Definition: IdDictFieldImplementation.h:66
IdDictFieldImplementation::m_ored_field
Range::field m_ored_field
Definition: IdDictFieldImplementation.h:110
str
Definition: BTagTrackIpAccessor.cxx:11
IdentifierField::optimize
void optimize()
Optimize - try to switch mode to both_bounded, set up lookup table for finding index from value.
Definition: IdentifierField.cxx:422
value_type
Definition: EDM_MasterSearch.h:11
IdDictFieldImplementation::m_shift
size_type m_shift
Definition: IdDictFieldImplementation.h:115
IdDictFieldImplementation::size_type
Identifier::size_type size_type
Definition: IdDictFieldImplementation.h:62
IdDictFieldImplementation::bits
size_type bits() const
Definition: IdDictFieldImplementation.h:202