ATLAS Offline Software
Public Member Functions | Private Member Functions | Private Attributes | List of all members
Trk::BinnedArrayArray< T > Class Template Referencefinal

#include <BinnedArrayArray.h>

Inheritance diagram for Trk::BinnedArrayArray< T >:
Collaboration diagram for Trk::BinnedArrayArray< T >:

Public Member Functions

 BinnedArrayArray (const std::vector< std::pair< BinnedArray< T > *, Amg::Vector3D >> &tbas, BinUtility *bUtility)
 Default Constructor
More...
 
 BinnedArrayArray (const BinnedArrayArray &baa)
 Copy Constructor. More...
 
virtual ~BinnedArrayArray ()
 Virtual Destructor. More...
 
BinnedArrayArrayoperator= (const BinnedArrayArray &baa)
 assignment operator matching the copy constructor More...
 
virtual BinnedArrayArrayclone () const override
 Implicit constructor. More...
 
virtual T * object (const Amg::Vector2D &lp) const override
 Returns the pointer to the templated class object from the BinnedArrayArray, it returns 0 if not defined, takes local position. More...
 
virtual T * object (const Amg::Vector3D &gp) const override
 Returns the pointer to the templated class object from the BinnedArrayArray it returns 0 if not defined, takes global position. More...
 
virtual T * entryObject (const Amg::Vector3D &gp) const override
 Returns the pointer to the templated class object from the BinnedArrayArray - entry point. More...
 
virtual T * nextObject (const Amg::Vector3D &gp, const Amg::Vector3D &, bool) const override
 Returns the pointer to the templated class object from the BinnedArrayArray, takes 3D position & direction. More...
 
virtual BinnedArraySpan< T *constarrayObjects () override final
 Return all objects of the Array non-const T. More...
 
virtual BinnedArraySpan< T const *constarrayObjects () const override final
 Return all objects of the Array const T. More...
 
virtual unsigned int arrayObjectsNumber () const override final
 Number of Entries in the Array. More...
 
virtual const BinUtilitybinUtility () const override
 Return the BinUtility. More...
 

Private Member Functions

void deleteBinnedArrays ()
 cleanup the array of binned arrays. More...
 
void copyBinnedArrays (const std::vector< BinnedArray< T > * > &binned_arrays)
 Build up binned arrays array from cloned binned arrays. More...
 

Private Attributes

BinUtilitym_binUtility
 
std::vector< BinnedArray< T > * > m_binnedArrays
 
std::vector< T * > m_arrayObjects
 

Detailed Description

template<class T>
class Trk::BinnedArrayArray< T >

the most generic extension of a BinnedArray: a BinnedArray of BinnedArrays voila

Author
Andre.nosp@m.as.S.nosp@m.alzbu.nosp@m.rger.nosp@m.@cern.nosp@m..ch

Definition at line 35 of file BinnedArrayArray.h.

Constructor & Destructor Documentation

◆ BinnedArrayArray() [1/2]

template<class T >
Trk::BinnedArrayArray< T >::BinnedArrayArray ( const std::vector< std::pair< BinnedArray< T > *, Amg::Vector3D >> &  tbas,
BinUtility bUtility 
)
inline

Default Constructor

Definition at line 40 of file BinnedArrayArray.h.

43  : m_binUtility(bUtility)
44  , m_binnedArrays(bUtility->bins(0), nullptr)
45  , m_arrayObjects()
46  {
47  // the array objects
48  m_arrayObjects.reserve(tbas.size() * bUtility->bins(0));
49  // looping over the contained binned arraysa
50  for (auto& barray : tbas) {
51  // binned array ordering
52  m_binnedArrays[bUtility->bin(barray.second, 0)] = barray.first;
53  // get the array objects
54  BinnedArraySpan<T * const > aObjects = barray.first->arrayObjects();
55  for (auto& o : aObjects)
56  m_arrayObjects.push_back(o);
57  }
58  }

◆ BinnedArrayArray() [2/2]

template<class T >
Trk::BinnedArrayArray< T >::BinnedArrayArray ( const BinnedArrayArray< T > &  baa)
inline

Copy Constructor.

Definition at line 61 of file BinnedArrayArray.h.

62  : m_binUtility(baa.m_binUtility->clone())
63  , m_arrayObjects(baa.m_arrayObjects)
64  {
65  copyBinnedArrays(baa.m_binnedArrays);
66  }

◆ ~BinnedArrayArray()

template<class T >
virtual Trk::BinnedArrayArray< T >::~BinnedArrayArray ( )
inlinevirtual

Virtual Destructor.

Definition at line 69 of file BinnedArrayArray.h.

70  {
71  delete m_binUtility;
73  }

Member Function Documentation

◆ arrayObjects() [1/2]

template<class T >
virtual BinnedArraySpan<T const * const> Trk::BinnedArrayArray< T >::arrayObjects ( ) const
inlinefinaloverridevirtual

Return all objects of the Array const T.

Implements Trk::BinnedArray< T >.

Definition at line 143 of file BinnedArrayArray.h.

144  {
145  return BinnedArraySpan<T const* const>(&*m_arrayObjects.begin(), &*m_arrayObjects.end());
146  }

◆ arrayObjects() [2/2]

template<class T >
virtual BinnedArraySpan<T* const > Trk::BinnedArrayArray< T >::arrayObjects ( )
inlinefinaloverridevirtual

Return all objects of the Array non-const T.

Implements Trk::BinnedArray< T >.

Definition at line 137 of file BinnedArrayArray.h.

138  {
139  return BinnedArraySpan<T* const >(&*m_arrayObjects.begin(), &*m_arrayObjects.end());
140  }

◆ arrayObjectsNumber()

template<class T >
virtual unsigned int Trk::BinnedArrayArray< T >::arrayObjectsNumber ( ) const
inlinefinaloverridevirtual

Number of Entries in the Array.

Implements Trk::BinnedArray< T >.

Definition at line 149 of file BinnedArrayArray.h.

150  {
151  return m_arrayObjects.size();
152  };

◆ binUtility()

template<class T >
virtual const BinUtility* Trk::BinnedArrayArray< T >::binUtility ( ) const
inlineoverridevirtual

Return the BinUtility.

Implements Trk::BinnedArray< T >.

Definition at line 155 of file BinnedArrayArray.h.

155 { return m_binUtility; }

◆ clone()

template<class T >
virtual BinnedArrayArray* Trk::BinnedArrayArray< T >::clone ( ) const
inlineoverridevirtual

Implicit constructor.

Implements Trk::BinnedArray< T >.

Definition at line 91 of file BinnedArrayArray.h.

92  {
93  return new BinnedArrayArray(*this);
94  }

◆ copyBinnedArrays()

template<class T >
void Trk::BinnedArrayArray< T >::copyBinnedArrays ( const std::vector< BinnedArray< T > * > &  binned_arrays)
inlineprivate

Build up binned arrays array from cloned binned arrays.

Note: the original m_binnedArrays is not automatically cleaned but requires deleteBinnedArrays to be called explicitly.

Definition at line 172 of file BinnedArrayArray.h.

173  {
174  m_binnedArrays.reserve(binned_arrays.size());
175 
176  for (const auto& a_binned_array : binned_arrays) {
177  m_binnedArrays.push_back(a_binned_array->clone());
178  }
179  }

◆ deleteBinnedArrays()

template<class T >
void Trk::BinnedArrayArray< T >::deleteBinnedArrays ( )
inlineprivate

cleanup the array of binned arrays.

Definition at line 160 of file BinnedArrayArray.h.

161  {
162  for (auto ba : m_binnedArrays) {
163  delete ba;
164  }
165  m_binnedArrays.clear();
166  }

◆ entryObject()

template<class T >
virtual T* Trk::BinnedArrayArray< T >::entryObject ( const Amg::Vector3D gp) const
inlineoverridevirtual

Returns the pointer to the templated class object from the BinnedArrayArray - entry point.

Implements Trk::BinnedArray< T >.

Definition at line 122 of file BinnedArrayArray.h.

123  {
124  return object(gp);
125  }

◆ nextObject()

template<class T >
virtual T* Trk::BinnedArrayArray< T >::nextObject ( const Amg::Vector3D gp,
const Amg::Vector3D ,
bool   
) const
inlineoverridevirtual

Returns the pointer to the templated class object from the BinnedArrayArray, takes 3D position & direction.

Implements Trk::BinnedArray< T >.

Definition at line 129 of file BinnedArrayArray.h.

132  {
133  return object(gp);
134  }

◆ object() [1/2]

template<class T >
virtual T* Trk::BinnedArrayArray< T >::object ( const Amg::Vector2D lp) const
inlineoverridevirtual

Returns the pointer to the templated class object from the BinnedArrayArray, it returns 0 if not defined, takes local position.

Implements Trk::BinnedArray< T >.

Definition at line 98 of file BinnedArrayArray.h.

99  {
100  if (m_binUtility->inside(lp)) {
101  BinnedArray<T>* ba = m_binnedArrays[m_binUtility->bin(lp, 0)];
102  if (ba)
103  return ba->object(lp);
104  }
105  return nullptr;
106  }

◆ object() [2/2]

template<class T >
virtual T* Trk::BinnedArrayArray< T >::object ( const Amg::Vector3D gp) const
inlineoverridevirtual

Returns the pointer to the templated class object from the BinnedArrayArray it returns 0 if not defined, takes global position.

Implements Trk::BinnedArray< T >.

Definition at line 110 of file BinnedArrayArray.h.

111  {
112  if (m_binUtility->inside(gp)) {
113  BinnedArray<T>* ba = m_binnedArrays[m_binUtility->bin(gp, 0)];
114  if (ba)
115  return ba->object(gp);
116  }
117  return nullptr;
118  }

◆ operator=()

template<class T >
BinnedArrayArray& Trk::BinnedArrayArray< T >::operator= ( const BinnedArrayArray< T > &  baa)
inline

assignment operator matching the copy constructor

Definition at line 76 of file BinnedArrayArray.h.

77  {
78  if (&baa != this) {
79  delete m_binUtility;
80  m_binUtility = baa.m_binUtility->clone();
81 
83  copyBinnedArrays(baa.m_binnedArrays);
84 
85  m_arrayObjects = baa.m_arrayObjects;
86  }
87  return *this;
88  }

Member Data Documentation

◆ m_arrayObjects

template<class T >
std::vector<T*> Trk::BinnedArrayArray< T >::m_arrayObjects
private

Definition at line 183 of file BinnedArrayArray.h.

◆ m_binnedArrays

template<class T >
std::vector<BinnedArray<T>*> Trk::BinnedArrayArray< T >::m_binnedArrays
private

Definition at line 182 of file BinnedArrayArray.h.

◆ m_binUtility

template<class T >
BinUtility* Trk::BinnedArrayArray< T >::m_binUtility
private

Definition at line 181 of file BinnedArrayArray.h.


The documentation for this class was generated from the following file:
Trk::BinnedArrayArray::m_binUtility
BinUtility * m_binUtility
Definition: BinnedArrayArray.h:181
Trk::BinnedArrayArray::deleteBinnedArrays
void deleteBinnedArrays()
cleanup the array of binned arrays.
Definition: BinnedArrayArray.h:160
Trk::BinnedArrayArray::BinnedArrayArray
BinnedArrayArray(const std::vector< std::pair< BinnedArray< T > *, Amg::Vector3D >> &tbas, BinUtility *bUtility)
Default Constructor
Definition: BinnedArrayArray.h:40
Trk::BinUtility::inside
bool inside(const Amg::Vector3D &position) const
Check if bin is inside from Vector3D.
Definition: BinUtility.h:190
Trk::BinnedArrayArray::copyBinnedArrays
void copyBinnedArrays(const std::vector< BinnedArray< T > * > &binned_arrays)
Build up binned arrays array from cloned binned arrays.
Definition: BinnedArrayArray.h:172
Trk::BinnedArrayArray::object
virtual T * object(const Amg::Vector2D &lp) const override
Returns the pointer to the templated class object from the BinnedArrayArray, it returns 0 if not defi...
Definition: BinnedArrayArray.h:98
Trk::BinUtility::clone
BinUtility * clone() const
Implizit Constructor.
Definition: BinUtility.h:130
Trk::BinnedArrayArray::m_binnedArrays
std::vector< BinnedArray< T > * > m_binnedArrays
Definition: BinnedArrayArray.h:182
Trk::BinUtility::bin
size_t bin(const Amg::Vector3D &position, size_t ba=0) const
Bin from a 3D vector (already in binning frame)
Definition: BinUtility.h:136
Trk::BinnedArrayArray::m_arrayObjects
std::vector< T * > m_arrayObjects
Definition: BinnedArrayArray.h:183