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 36 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 41 of file FPGATrackSimGenScanArray.h.

42  {
43  setsize(dims, initval);
44  }

Member Function Documentation

◆ begin()

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

Definition at line 186 of file FPGATrackSimGenScanArray.h.

186 { 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 74 of file FPGATrackSimGenScanArray.h.

74 { return m_dims; }

◆ end()

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

Definition at line 187 of file FPGATrackSimGenScanArray.h.

188  {
189  std::vector<unsigned int> retv;
190  for (auto &d : m_dims)
191  retv.push_back(d - 1);
192  return ++Iterator(retv, *this);
193  }

◆ flatdata()

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

Definition at line 71 of file FPGATrackSimGenScanArray.h.

71 {return m_data;}

◆ operator[]() [1/4]

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

Definition at line 112 of file FPGATrackSimGenScanArray.h.

112  {
113  T& retv ATLAS_THREAD_SAFE = const_cast<T&>(std::as_const(*this)[idx]);
114  return retv;
115  }

◆ operator[]() [2/4]

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

Definition at line 101 of file FPGATrackSimGenScanArray.h.

102  {
103  std::vector<unsigned int> idx_unsigned;
104  for (auto &d : idx)
105  idx_unsigned.push_back(d);
106  return (*this)[idx_unsigned];
107  }

◆ operator[]() [3/4]

template<typename T >
T& FPGATrackSimGenScanArray< T >::operator[] ( const std::vector< unsigned > &  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[]() [4/4]

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

Definition at line 77 of file FPGATrackSimGenScanArray.h.

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

◆ setsize()

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

Definition at line 47 of file FPGATrackSimGenScanArray.h.

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

◆ size()

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

Definition at line 65 of file FPGATrackSimGenScanArray.h.

65 { return m_entries; }

Member Data Documentation

◆ m_data

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

Definition at line 199 of file FPGATrackSimGenScanArray.h.

◆ m_dims

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

Definition at line 197 of file FPGATrackSimGenScanArray.h.

◆ m_entries

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

Definition at line 196 of file FPGATrackSimGenScanArray.h.

◆ m_step

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

Definition at line 198 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:74
FPGATrackSimGenScanArray::m_step
std::vector< unsigned int > m_step
Definition: FPGATrackSimGenScanArray.h:198
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:196
lumiFormat.i
int i
Definition: lumiFormat.py:85
FPGATrackSimGenScanArray::m_dims
std::vector< unsigned int > m_dims
Definition: FPGATrackSimGenScanArray.h:197
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:199
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:47
TSU::T
unsigned long long T
Definition: L1TopoDataTypes.h:35