ATLAS Offline Software
Classes | Public Member Functions | Private Attributes | List of all members
FPGATrackSimGenScanArray< T > Class Template Reference

#include <FPGATrackSimGenScanArray.h>

Collaboration diagram for FPGATrackSimGenScanArray< T >:

Classes

struct  Iterator
 

Public Member Functions

 FPGATrackSimGenScanArray ()=default
 
 FPGATrackSimGenScanArray (const std::vector< unsigned int > &dims, const T &initval)
 
void setsize (const std::vector< unsigned int > &dims, const T &initval)
 
unsigned int size () const
 
const std::vector< T > & flatdata () const
 
const std::vector< unsigned int > & dims () const
 
const T & operator[] (const std::vector< unsigned int > &idx) const
 
const T & operator[] (const std::vector< int > &idx) const
 
T & operator[] (const std::vector< int > &idx)
 
T & operator[] (const std::vector< unsigned > &idx)
 
Iterator begin ()
 
Iterator end ()
 

Private Attributes

unsigned int m_entries {}
 
std::vector< unsigned int > m_dims {}
 
std::vector< unsigned int > m_step {}
 
std::vector< T > m_data {}
 

Detailed Description

template<typename T>
class FPGATrackSimGenScanArray< T >

Definition at line 40 of file FPGATrackSimGenScanArray.h.

Constructor & Destructor Documentation

◆ FPGATrackSimGenScanArray() [1/2]

template<typename T >
FPGATrackSimGenScanArray< T >::FPGATrackSimGenScanArray ( )
default

◆ FPGATrackSimGenScanArray() [2/2]

template<typename T >
FPGATrackSimGenScanArray< T >::FPGATrackSimGenScanArray ( const std::vector< unsigned int > &  dims,
const T &  initval 
)
inline

Definition at line 45 of file FPGATrackSimGenScanArray.h.

46  {
47  setsize(dims, initval);
48  }

Member Function Documentation

◆ begin()

template<typename T >
Iterator FPGATrackSimGenScanArray< T >::begin ( )
inline

Definition at line 190 of file FPGATrackSimGenScanArray.h.

190 { return Iterator(std::vector<unsigned int>(m_dims.size(), 0), *this); }

◆ dims()

template<typename T >
const std::vector<unsigned int>& FPGATrackSimGenScanArray< T >::dims ( ) const
inline

Definition at line 78 of file FPGATrackSimGenScanArray.h.

78 { return m_dims; }

◆ end()

template<typename T >
Iterator FPGATrackSimGenScanArray< T >::end ( )
inline

Definition at line 191 of file FPGATrackSimGenScanArray.h.

192  {
193  std::vector<unsigned int> retv;
194  for (auto &d : m_dims)
195  retv.push_back(d - 1);
196  return ++Iterator(retv, *this);
197  }

◆ flatdata()

template<typename T >
const std::vector<T>& FPGATrackSimGenScanArray< T >::flatdata ( ) const
inline

Definition at line 75 of file FPGATrackSimGenScanArray.h.

75 {return m_data;}

◆ operator[]() [1/4]

template<typename T >
T& FPGATrackSimGenScanArray< T >::operator[] ( const std::vector< int > &  idx)
inline

Definition at line 116 of file FPGATrackSimGenScanArray.h.

116  {
117  T& retv ATLAS_THREAD_SAFE = const_cast<T&>(std::as_const(*this)[idx]);
118  return retv;
119  }

◆ operator[]() [2/4]

template<typename T >
const T& FPGATrackSimGenScanArray< T >::operator[] ( const std::vector< int > &  idx) const
inline

Definition at line 105 of file FPGATrackSimGenScanArray.h.

106  {
107  std::vector<unsigned int> idx_unsigned;
108  for (auto &d : idx)
109  idx_unsigned.push_back(d);
110  return (*this)[idx_unsigned];
111  }

◆ operator[]() [3/4]

template<typename T >
T& FPGATrackSimGenScanArray< T >::operator[] ( const std::vector< unsigned > &  idx)
inline

Definition at line 120 of file FPGATrackSimGenScanArray.h.

120  {
121  T &retv ATLAS_THREAD_SAFE = const_cast<T &>(std::as_const(*this)[idx]);
122  return retv;
123  }

◆ operator[]() [4/4]

template<typename T >
const T& FPGATrackSimGenScanArray< T >::operator[] ( const std::vector< unsigned int > &  idx) const
inline

Definition at line 81 of file FPGATrackSimGenScanArray.h.

82  {
83  if(idx.size() != m_step.size()) {
84  throw std::runtime_error("FPGATrackSimGenScanArray: index size does not match array dimensions");
85  }
86 
87  // Translate N-dim index to 1-d index
88  unsigned int offset = 0;
89  for (unsigned int i = 0; i < m_step.size(); i++)
90  {
91  if (idx.at(i) >= m_dims.at(i))
92  {
93  throw std::runtime_error("FPGATrackSimGenScanArray: index out of range i=" + std::to_string(i) +
94  " idx[i]=" + std::to_string(idx.at(i)) +
95  " dims[i]=" + std::to_string(m_dims.at(i)) + "\n");
96  }
97  offset += idx.at(i) * m_step.at(i);
98  }
99 
100  // Return data from 1-d vector
101  return m_data.at(offset);
102  }

◆ setsize()

template<typename T >
void FPGATrackSimGenScanArray< T >::setsize ( const std::vector< unsigned int > &  dims,
const T &  initval 
)
inline

Definition at line 51 of file FPGATrackSimGenScanArray.h.

52  {
53  m_dims = dims;
54 
55  // Caclulate the number of entries and a "step"-size needed for translating
56  // N-dim indices into a 1-d index
57  m_entries = 1;
58  for (auto &dim : dims)
59  {
60  m_step.push_back(m_entries);
61  m_entries *= dim;
62  }
63 
64  // Allocate 1-d array
65  m_data.resize(m_entries, initval);
66  }

◆ size()

template<typename T >
unsigned int FPGATrackSimGenScanArray< T >::size ( ) const
inline

Definition at line 69 of file FPGATrackSimGenScanArray.h.

69 { return m_entries; }

Member Data Documentation

◆ m_data

template<typename T >
std::vector<T> FPGATrackSimGenScanArray< T >::m_data {}
private

Definition at line 203 of file FPGATrackSimGenScanArray.h.

◆ m_dims

template<typename T >
std::vector<unsigned int> FPGATrackSimGenScanArray< T >::m_dims {}
private

Definition at line 201 of file FPGATrackSimGenScanArray.h.

◆ m_entries

template<typename T >
unsigned int FPGATrackSimGenScanArray< T >::m_entries {}
private

Definition at line 200 of file FPGATrackSimGenScanArray.h.

◆ m_step

template<typename T >
std::vector<unsigned int> FPGATrackSimGenScanArray< T >::m_step {}
private

Definition at line 202 of file FPGATrackSimGenScanArray.h.


The documentation for this class was generated from the following file:
FPGATrackSimGenScanArray::dims
const std::vector< unsigned int > & dims() const
Definition: FPGATrackSimGenScanArray.h:78
FPGATrackSimGenScanArray::m_step
std::vector< unsigned int > m_step
Definition: FPGATrackSimGenScanArray.h:202
yodamerge_tmp.dim
dim
Definition: yodamerge_tmp.py:239
hist_file_dump.d
d
Definition: hist_file_dump.py:137
FPGATrackSimGenScanArray::m_entries
unsigned int m_entries
Definition: FPGATrackSimGenScanArray.h:200
lumiFormat.i
int i
Definition: lumiFormat.py:85
FPGATrackSimGenScanArray::m_dims
std::vector< unsigned int > m_dims
Definition: FPGATrackSimGenScanArray.h:201
ActsTrk::to_string
std::string to_string(const DetectorType &type)
Definition: GeometryDefs.h:34
convertTimingResiduals.offset
offset
Definition: convertTimingResiduals.py:71
LArNewCalib_DelayDump_OFC_Cali.idx
idx
Definition: LArNewCalib_DelayDump_OFC_Cali.py:69
FPGATrackSimGenScanArray::m_data
std::vector< T > m_data
Definition: FPGATrackSimGenScanArray.h:203
ATLAS_THREAD_SAFE
#define ATLAS_THREAD_SAFE
Definition: checker_macros.h:211
FPGATrackSimGenScanArray::setsize
void setsize(const std::vector< unsigned int > &dims, const T &initval)
Definition: FPGATrackSimGenScanArray.h:51
TSU::T
unsigned long long T
Definition: L1TopoDataTypes.h:35