ATLAS Offline Software
Loading...
Searching...
No Matches
PhaseII::InDetRawDataContainer< NDim > Class Template Reference

Base raw data container which provides coordinates of a certain dimension and a data word per RDO (raw data object). More...

#include <PhaseIIInDetRawDataContainer.h>

Collaboration diagram for PhaseII::InDetRawDataContainer< NDim >:

Public Member Functions

bool isValid (unsigned int index) const
 return true if the index refers to an element in the container
const std::array< std::int16_t, NDim > & coordinates (unsigned int index) const
 return the coordinates i.e. column, row or strip of a certain RDO (read only).
std::array< std::int16_t, NDim > & coordinates (unsigned int index)
 return the coordinates i.e. column, row or strip of a certain RDO.
const std::uint32_t & dataWord (unsigned int index) const
 return the packed data word of of a certain RDO (read only).
std::uint32_t & dataWord (unsigned int index)
 return the packed data word of of a certain RDO.
bool isSane () const
std::size_t size () const
 total number of RDOs which are in this container.
bool empty () const
 test whether the container is empty i.e. does not contain any RDOs
std::size_t capacity () const
 the maximum number RDOs this container can hold without reallocation.
void reserve (std::size_t new_capacity)
 reserve space for a certain number of RDOs.
void emplace_back (std::array< std::int16_t, NDim > &&coordinates, std::uint32_t data_word)
 Add a new RDO to the end of this container.
void erase_back (unsigned int begin_index)
 erase the elements at the end of the container
void move (InDetRawDataContainer &dest, unsigned int start_index)
 Move the coordinates and the data word of a certain number of elements at the end to a new container.

Static Public Member Functions

static constexpr int unpack (std::uint32_t mask, unsigned int shift, unsigned int word)
 extract a value from a bit packed word.
static constexpr std::uint32_t pack (std::uint32_t mask, unsigned int shift, int input)
 Create a bit-packed word from an input value.

Private Attributes

std::vector< std::array< std::int16_t, NDim > > m_coordinates
std::vector< std::uint32_t > m_word

Detailed Description

template<std::size_t NDim>
class PhaseII::InDetRawDataContainer< NDim >

Base raw data container which provides coordinates of a certain dimension and a data word per RDO (raw data object).

The class implements the basic container methods to allow its usage together with proxy container objects It also provides methods to bit-pack and unpack information into and from a single data word.

Definition at line 245 of file PhaseIIInDetRawDataContainer.h.

Member Function Documentation

◆ capacity()

template<std::size_t NDim>
std::size_t PhaseII::InDetRawDataContainer< NDim >::capacity ( ) const
inline

the maximum number RDOs this container can hold without reallocation.

Definition at line 269 of file PhaseIIInDetRawDataContainer.h.

269{ assert(m_coordinates.capacity() == m_word.capacity()); return m_coordinates.capacity(); }
Base raw data container which provides coordinates of a certain dimension and a data word per RDO (ra...
std::vector< std::array< std::int16_t, NDim > > m_coordinates

◆ coordinates() [1/2]

template<std::size_t NDim>
std::array< std::int16_t, NDim > & PhaseII::InDetRawDataContainer< NDim >::coordinates ( unsigned int index)
inline

return the coordinates i.e. column, row or strip of a certain RDO.

Definition at line 254 of file PhaseIIInDetRawDataContainer.h.

254{ assert(isValid(index)); return m_coordinates[index]; }
bool isValid(unsigned int index) const
return true if the index refers to an element in the container

◆ coordinates() [2/2]

template<std::size_t NDim>
const std::array< std::int16_t, NDim > & PhaseII::InDetRawDataContainer< NDim >::coordinates ( unsigned int index) const
inline

return the coordinates i.e. column, row or strip of a certain RDO (read only).

Definition at line 252 of file PhaseIIInDetRawDataContainer.h.

252{ assert(isValid(index)); return m_coordinates[index]; }

◆ dataWord() [1/2]

template<std::size_t NDim>
std::uint32_t & PhaseII::InDetRawDataContainer< NDim >::dataWord ( unsigned int index)
inline

return the packed data word of of a certain RDO.

Definition at line 258 of file PhaseIIInDetRawDataContainer.h.

258{ assert(isValid(index)); return m_word[index]; }

◆ dataWord() [2/2]

template<std::size_t NDim>
const std::uint32_t & PhaseII::InDetRawDataContainer< NDim >::dataWord ( unsigned int index) const
inline

return the packed data word of of a certain RDO (read only).

Definition at line 256 of file PhaseIIInDetRawDataContainer.h.

256{ assert(isValid(index)); return m_word[index]; }

◆ emplace_back()

template<std::size_t NDim>
void PhaseII::InDetRawDataContainer< NDim >::emplace_back ( std::array< std::int16_t, NDim > && coordinates,
std::uint32_t data_word )
inline

Add a new RDO to the end of this container.

Parameters
coordinatesthe coordinates of the RDO e.g. pixel row, column or strop.
data_worda bit packed data word which may contain e.g. the ToT.

Definition at line 281 of file PhaseIIInDetRawDataContainer.h.

281 {
282 // @TODO should bail out if container is filled concurrently and the
283 // size is equal to the capacity, but the container does not know.
284 m_coordinates.emplace_back(std::move(coordinates));
285 m_word.emplace_back(data_word);
286 assert(isSane());
287 }
const std::array< std::int16_t, NDim > & coordinates(unsigned int index) const
return the coordinates i.e. column, row or strip of a certain RDO (read only).

◆ empty()

template<std::size_t NDim>
bool PhaseII::InDetRawDataContainer< NDim >::empty ( ) const
inline

test whether the container is empty i.e. does not contain any RDOs

Definition at line 267 of file PhaseIIInDetRawDataContainer.h.

267{ assert(isSane()); return m_coordinates.empty(); }

◆ erase_back()

template<std::size_t NDim>
void PhaseII::InDetRawDataContainer< NDim >::erase_back ( unsigned int begin_index)
inline

erase the elements at the end of the container

Parameters
begin_indexthe index of the first element that is erased. Will erase all elements from begin_index till the end of the container. begin_index is expected to be smaller or equal to the container size. The result may be undefined if begin_index is larger than the container size.

Definition at line 294 of file PhaseIIInDetRawDataContainer.h.

294 {
295 assert( begin_index <= m_coordinates.size());
297 m_word.erase( m_word.begin()+begin_index, m_word.end());
298 assert(isSane());
299 }

◆ isSane()

template<std::size_t NDim>
bool PhaseII::InDetRawDataContainer< NDim >::isSane ( ) const
inline

Definition at line 262 of file PhaseIIInDetRawDataContainer.h.

262{ return m_coordinates.size() == m_word.size(); }

◆ isValid()

template<std::size_t NDim>
bool PhaseII::InDetRawDataContainer< NDim >::isValid ( unsigned int index) const
inline

return true if the index refers to an element in the container

Definition at line 249 of file PhaseIIInDetRawDataContainer.h.

249{ assert( m_coordinates.size() == m_word.size()); return index < m_coordinates.size(); }

◆ move()

template<std::size_t NDim>
void PhaseII::InDetRawDataContainer< NDim >::move ( InDetRawDataContainer< NDim > & dest,
unsigned int start_index )
inline

Move the coordinates and the data word of a certain number of elements at the end to a new container.

Parameters
destthe container to which the elements will be moved.
start_indexthe index of the first element that will be moved. Will copy the elements from start_index until then end to the container dest, and erase the copied elements from this container.

Definition at line 330 of file PhaseIIInDetRawDataContainer.h.

330 {
331 unsigned int copy_n_elements=size()-start_index;
335 std::memcpy(dest.m_word.data(), m_word.data()+start_index, copy_n_elements*sizeof(typename decltype(m_word)::value_type) );
336 this->erase_back(start_index);
337 }
std::size_t size() const
total number of RDOs which are in this container.
void erase_back(unsigned int begin_index)
erase the elements at the end of the container

◆ pack()

template<std::size_t NDim>
constexpr std::uint32_t PhaseII::InDetRawDataContainer< NDim >::pack ( std::uint32_t mask,
unsigned int shift,
int input )
inlinestaticconstexpr

Create a bit-packed word from an input value.

Parameters
maskthe mask to blend out bits of the input value which are not part of the actual value.
shiftthe bit number of the first bit in the bit packed data word.
inputthe input value.
Returns
a bit packed data word which only represents the input value. This value can be or-ed with other bit-packed values to form a complete data word. If the input value exceeds the maximum value fitting into the provided mask, then the result will be undefined.

Definition at line 319 of file PhaseIIInDetRawDataContainer.h.

319 {
320 // test that packing is loss-less
321 assert( static_cast<int>(static_cast<std::uint32_t>(input) & mask) ==input );
322 return static_cast<std::uint32_t>( (input & mask) << shift );
323 }

◆ reserve()

template<std::size_t NDim>
void PhaseII::InDetRawDataContainer< NDim >::reserve ( std::size_t new_capacity)
inline

reserve space for a certain number of RDOs.

Definition at line 272 of file PhaseIIInDetRawDataContainer.h.

272 {
274 m_word.reserve(new_capacity);
275 assert(isSane() && m_coordinates.capacity() == m_word.capacity());
276 }

◆ size()

template<std::size_t NDim>
std::size_t PhaseII::InDetRawDataContainer< NDim >::size ( ) const
inline

total number of RDOs which are in this container.

Definition at line 265 of file PhaseIIInDetRawDataContainer.h.

265{ assert(isSane()); return m_coordinates.size(); }

◆ unpack()

template<std::size_t NDim>
constexpr int PhaseII::InDetRawDataContainer< NDim >::unpack ( std::uint32_t mask,
unsigned int shift,
unsigned int word )
inlinestaticconstexpr

extract a value from a bit packed word.

Parameters
maskthe mask to blend out bits not part of a certain value after shifting the data word.
shiftthe first bit of the value
wordthe bit packed data word
Returns
the unpacked value Will shift the data word and then apply the mask to blend out bits not part of the value.

Definition at line 307 of file PhaseIIInDetRawDataContainer.h.

307 {
308 return static_cast<int>( (word >> shift ) & mask );
309 }

Member Data Documentation

◆ m_coordinates

template<std::size_t NDim>
std::vector<std::array<std::int16_t,NDim> > PhaseII::InDetRawDataContainer< NDim >::m_coordinates
private

Definition at line 339 of file PhaseIIInDetRawDataContainer.h.

◆ m_word

template<std::size_t NDim>
std::vector<std::uint32_t> PhaseII::InDetRawDataContainer< NDim >::m_word
private

Definition at line 340 of file PhaseIIInDetRawDataContainer.h.


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