ATLAS Offline Software
Loading...
Searching...
No Matches
Trk::BinnedArray2D< T > Class Template Referencefinal

Avoiding a map search, the templated BinnedArray class can help ordereing geometrical objects by providing a dedicated BinUtility. More...

#include <BinnedArray2D.h>

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

Public Member Functions

 BinnedArray2D ()=default
 BinnedArray2D (BinnedArray2D &&)=default
BinnedArray2Doperator= (BinnedArray2D &&)=default
 ~BinnedArray2D ()=default
 BinnedArray2D (const std::vector< std::pair< std::shared_ptr< T >, Amg::Vector3D > > &tclassvector, const BinUtility &bingen)
 Constructors with arguments.
 BinnedArray2D (const std::vector< std::pair< std::shared_ptr< T >, Amg::Vector3D > > &tclassvector, BinUtility &&bingen)
 BinnedArray2D (const BinnedArray2D &barr)
 Copy Constructor !
BinnedArray2Doperator= (const BinnedArray2D &barr)
 Assignment operator.
BinnedArray2Dclone () const
 Implizit Constructor.
T * object (const Amg::Vector2D &lp) const
 Returns the pointer to the templated class object from the BinnedArray, it returns nullptr if not defined;.
T * object (const Amg::Vector3D &gp) const
 Returns the pointer to the templated class object from the BinnedArray it returns nullptr if not defined;.
T * entryObject (const Amg::Vector3D &pos) const
 Returns the pointer to the templated class object from the BinnedArray -entry point.
T * nextObject (const Amg::Vector3D &gp, const Amg::Vector3D &mom, bool associatedResult=true) const
 Returns the pointer to the templated class object from the BinnedArray.
std::span< T *const > arrayObjects ()
 Return all objects of the Array non-const T.
std::span< T const *const > arrayObjects () const
 Return all objects of the Array const T.
unsigned int arrayObjectsNumber () const
 Number of Entries in the Array.
const BinUtilitybinUtility () const
 Return the BinUtility.

Private Member Functions

void createArrayCache () const
void initialize (const std::vector< std::pair< std::shared_ptr< T >, Amg::Vector3D > > &tclassvector)
 vector of pointers to the class T

Private Attributes

std::vector< std::vector< std::shared_ptr< T > > > m_array {}
 1D vector of cached not owning pointers to class T
CxxUtils::CachedUniquePtr< std::vector< T * > > m_arrayObjects {nullptr}
 binUtility for retrieving and filling the Array
BinUtility m_binUtility {}

Detailed Description

template<class T>
class Trk::BinnedArray2D< T >

Avoiding a map search, the templated BinnedArray class can help ordereing geometrical objects by providing a dedicated BinUtility.

dedicated for 2-dim equidistant binning

Author
Andre.nosp@m.as.S.nosp@m.alzbu.nosp@m.rger.nosp@m.@cern.nosp@m..ch
Christos Anastopoulos (Athena MT modifications)

Definition at line 36 of file BinnedArray2D.h.

Constructor & Destructor Documentation

◆ BinnedArray2D() [1/5]

template<class T>
Trk::BinnedArray2D< T >::BinnedArray2D ( )
default

◆ BinnedArray2D() [2/5]

template<class T>
Trk::BinnedArray2D< T >::BinnedArray2D ( BinnedArray2D< T > && )
default

◆ ~BinnedArray2D()

template<class T>
Trk::BinnedArray2D< T >::~BinnedArray2D ( )
default

◆ BinnedArray2D() [3/5]

template<class T>
Trk::BinnedArray2D< T >::BinnedArray2D ( const std::vector< std::pair< std::shared_ptr< T >, Amg::Vector3D > > & tclassvector,
const BinUtility & bingen )
inline

Constructors with arguments.

Definition at line 47 of file BinnedArray2D.h.

51 m_array{},
52 m_arrayObjects(nullptr),
55 }
Avoiding a map search, the templated BinnedArray class can help ordereing geometrical objects by prov...
BinUtility m_binUtility
CxxUtils::CachedUniquePtr< std::vector< T * > > m_arrayObjects
binUtility for retrieving and filling the Array
std::vector< std::vector< std::shared_ptr< T > > > m_array
1D vector of cached not owning pointers to class T
BinnedArray()=default
void initialize()

◆ BinnedArray2D() [4/5]

template<class T>
Trk::BinnedArray2D< T >::BinnedArray2D ( const std::vector< std::pair< std::shared_ptr< T >, Amg::Vector3D > > & tclassvector,
BinUtility && bingen )
inline

Definition at line 56 of file BinnedArray2D.h.

◆ BinnedArray2D() [5/5]

template<class T>
Trk::BinnedArray2D< T >::BinnedArray2D ( const BinnedArray2D< T > & barr)
inline

Copy Constructor !

Definition at line 67 of file BinnedArray2D.h.

Member Function Documentation

◆ arrayObjects() [1/2]

template<class T>
std::span< T *const > Trk::BinnedArray2D< T >::arrayObjects ( )
inlinevirtual

Return all objects of the Array non-const T.

Implements Trk::BinnedArray< T >.

Definition at line 133 of file BinnedArray2D.h.

134 {
136 return std::span<T* const>(m_arrayObjects->begin(), m_arrayObjects->end());
137 }
void createArrayCache() const

◆ arrayObjects() [2/2]

template<class T>
std::span< T const *const > Trk::BinnedArray2D< T >::arrayObjects ( ) const
inlinevirtual

Return all objects of the Array const T.

Implements Trk::BinnedArray< T >.

Definition at line 140 of file BinnedArray2D.h.

141 {
144 }

◆ arrayObjectsNumber()

template<class T>
unsigned int Trk::BinnedArray2D< T >::arrayObjectsNumber ( ) const
inlinevirtual

Number of Entries in the Array.

Implements Trk::BinnedArray< T >.

Definition at line 147 of file BinnedArray2D.h.

148 {
149 return (m_array.size() * (m_array[0]).size());
150 }

◆ binUtility()

template<class T>
const BinUtility * Trk::BinnedArray2D< T >::binUtility ( ) const
inlinevirtual

Return the BinUtility.

Implements Trk::BinnedArray< T >.

Definition at line 153 of file BinnedArray2D.h.

153{ return &m_binUtility; }

◆ clone()

template<class T>
BinnedArray2D * Trk::BinnedArray2D< T >::clone ( ) const
inlinevirtual

Implizit Constructor.

Implements Trk::BinnedArray< T >.

Definition at line 84 of file BinnedArray2D.h.

84{ return new BinnedArray2D(*this); }
BinnedArray2D()=default

◆ createArrayCache()

template<class T>
void Trk::BinnedArray2D< T >::createArrayCache ( ) const
inlineprivate

Definition at line 156 of file BinnedArray2D.h.

157 {
158 if (!m_arrayObjects) {
161 for (size_t ihl = 0; ihl < (m_binUtility.bins(1)); ++ihl) {
162 for (size_t ill = 0; ill < (m_binUtility.bins(0)); ++ill) {
163 arrayObjects->push_back((m_array[ihl][ill]).get());
164 }
165 }
167 }
168 }
unsigned int arrayObjectsNumber() const
Number of Entries in the Array.
std::span< T *const > arrayObjects()
Return all objects of the Array non-const T.
T * get(TKey *tobj)
get a TObject* from a TKey* (why can't a TObject be a TKey?)
Definition hcg.cxx:130

◆ entryObject()

template<class T>
T * Trk::BinnedArray2D< T >::entryObject ( const Amg::Vector3D & pos) const
inlinevirtual

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

Implements Trk::BinnedArray< T >.

Definition at line 109 of file BinnedArray2D.h.

110 {
111 return (m_array[m_binUtility.entry(pos, 1)][m_binUtility.entry(pos, 0)]).get();
112 }

◆ initialize()

template<class T>
void Trk::BinnedArray2D< T >::initialize ( const std::vector< std::pair< std::shared_ptr< T >, Amg::Vector3D > > & tclassvector)
inlineprivate

vector of pointers to the class T

Definition at line 170 of file BinnedArray2D.h.

◆ nextObject()

template<class T>
T * Trk::BinnedArray2D< T >::nextObject ( const Amg::Vector3D & gp,
const Amg::Vector3D & mom,
bool associatedResult = true ) const
inlinevirtual

Returns the pointer to the templated class object from the BinnedArray.

Implements Trk::BinnedArray< T >.

Definition at line 116 of file BinnedArray2D.h.

119 {
120 // direct access to associated one
121 if (associatedResult){
122 return object(gp);
123 }
124 size_t nextFirst = m_binUtility.next(gp, mom, 0);
125 size_t nextSecond = m_binUtility.next(gp, mom, 1);
126
127 return (nextFirst > 0 && nextSecond > 0)
129 : nullptr;
130 }
T * object(const Amg::Vector2D &lp) const
Returns the pointer to the templated class object from the BinnedArray, it returns nullptr if not def...

◆ object() [1/2]

template<class T>
T * Trk::BinnedArray2D< T >::object ( const Amg::Vector2D & lp) const
inlinevirtual

Returns the pointer to the templated class object from the BinnedArray, it returns nullptr if not defined;.

Implements Trk::BinnedArray< T >.

Definition at line 89 of file BinnedArray2D.h.

90 {
91 if (m_binUtility.inside(lp)) {
92 return (m_array[m_binUtility.bin(lp, 1)][m_binUtility.bin(lp, 0)]).get();
93 }
94 return nullptr;
95 }

◆ object() [2/2]

template<class T>
T * Trk::BinnedArray2D< T >::object ( const Amg::Vector3D & gp) const
inlinevirtual

Returns the pointer to the templated class object from the BinnedArray it returns nullptr if not defined;.

Implements Trk::BinnedArray< T >.

Definition at line 99 of file BinnedArray2D.h.

100 {
101 if (m_binUtility.inside(gp)) {
102 return (m_array[m_binUtility.bin(gp, 1)][m_binUtility.bin(gp, 0)]).get();
103 }
104 return nullptr;
105 }

◆ operator=() [1/2]

template<class T>
BinnedArray2D & Trk::BinnedArray2D< T >::operator= ( BinnedArray2D< T > && )
default

◆ operator=() [2/2]

template<class T>
BinnedArray2D & Trk::BinnedArray2D< T >::operator= ( const BinnedArray2D< T > & barr)
inline

Assignment operator.

Definition at line 74 of file BinnedArray2D.h.

74 {
75 if (this != &barr) {
76 m_arrayObjects.release();
79 }
80 return *this;
81 }

Member Data Documentation

◆ m_array

template<class T>
std::vector<std::vector<std::shared_ptr<T> > > Trk::BinnedArray2D< T >::m_array {}
private

1D vector of cached not owning pointers to class T

Definition at line 189 of file BinnedArray2D.h.

189{};

◆ m_arrayObjects

template<class T>
CxxUtils::CachedUniquePtr<std::vector<T*> > Trk::BinnedArray2D< T >::m_arrayObjects {nullptr}
private

binUtility for retrieving and filling the Array

Definition at line 191 of file BinnedArray2D.h.

191{nullptr};

◆ m_binUtility

template<class T>
BinUtility Trk::BinnedArray2D< T >::m_binUtility {}
private

Definition at line 193 of file BinnedArray2D.h.

193{};

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