Loading [MathJax]/extensions/tex2jax.js
ATLAS Offline Software
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
Public Member Functions | Private Member Functions | Private Attributes | List of all members
Trk::BinnedArray2D< T > Class Template Referencefinal

#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< SharedObject< T >, Amg::Vector3D >> &tclassvector, const BinUtility &bingen)
 Constructors with arguments. More...
 
 BinnedArray2D (const std::vector< std::pair< SharedObject< T >, Amg::Vector3D >> &tclassvector, BinUtility &&bingen)
 
 BinnedArray2D (const BinnedArray2D &barr)
 Copy Constructor ! More...
 
BinnedArray2Doperator= (const BinnedArray2D &barr)
 Assignment operator. More...
 
BinnedArray2Dclone () const
 Implizit Constructor. More...
 
T * object (const Amg::Vector2D &lp) const
 Returns the pointer to the templated class object from the BinnedArray, it returns nullptr if not defined;. More...
 
T * object (const Amg::Vector3D &gp) const
 Returns the pointer to the templated class object from the BinnedArray it returns nullptr if not defined;. More...
 
T * entryObject (const Amg::Vector3D &pos) const
 Returns the pointer to the templated class object from the BinnedArray -entry point. More...
 
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. More...
 
BinnedArraySpan< T *constarrayObjects ()
 Return all objects of the Array non-const T. More...
 
BinnedArraySpan< T const *constarrayObjects () const
 Return all objects of the Array const T. More...
 
unsigned int arrayObjectsNumber () const
 Number of Entries in the Array. More...
 
const BinUtilitybinUtility () const
 Return the BinUtility. More...
 

Private Member Functions

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

Private Attributes

std::vector< std::vector< SharedObject< T > > > m_array {}
 1D vector of cached not owning pointers to class T More...
 
CxxUtils::CachedUniquePtr< std::vector< T * > > m_arrayObjects {nullptr}
 binUtility for retrieving and filling the Array More...
 
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< SharedObject< T >, Amg::Vector3D >> &  tclassvector,
const BinUtility bingen 
)
inline

Constructors with arguments.

Definition at line 47 of file BinnedArray2D.h.

50  : BinnedArray<T>(),
51  m_array{},
52  m_arrayObjects(nullptr),
53  m_binUtility(bingen) {
54  initialize(tclassvector);
55  }

◆ BinnedArray2D() [4/5]

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

Definition at line 56 of file BinnedArray2D.h.

59  : BinnedArray<T>(),
60  m_array{},
61  m_arrayObjects(nullptr),
62  m_binUtility(std::move(bingen)) {
63  initialize(tclassvector);
64  }

◆ 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.

68  : BinnedArray<T>(),
69  m_array{barr.m_array},
70  m_arrayObjects(nullptr),
71  m_binUtility(barr.m_binUtility) {}

Member Function Documentation

◆ arrayObjects() [1/2]

template<class T >
BinnedArraySpan<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 BinnedArraySpan<T* const>(&*(m_arrayObjects->begin()), &*(m_arrayObjects->end()));
137  }

◆ arrayObjects() [2/2]

template<class T >
BinnedArraySpan<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  {
143  return BinnedArraySpan<T const * const>(&*(m_arrayObjects->begin()), &*(m_arrayObjects->end()));
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); }

◆ createArrayCache()

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

Definition at line 156 of file BinnedArray2D.h.

157  {
158  if (!m_arrayObjects) {
159  std::unique_ptr<std::vector<T*>> arrayObjects = std::make_unique<std::vector<T*>>();
160  arrayObjects->reserve(arrayObjectsNumber());
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  }
166  m_arrayObjects.set(std::move(arrayObjects));
167  }
168  }

◆ 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< SharedObject< 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)
128  ? (m_array[nextSecond][nextFirst]).get()
129  : nullptr;
130  }

◆ 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();
77  m_binUtility = barr.m_binUtility;
78  m_array = barr.m_array;
79  }
80  return *this;
81  }

Member Data Documentation

◆ m_array

template<class T >
std::vector<std::vector<SharedObject<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.

◆ 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.

◆ m_binUtility

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

Definition at line 193 of file BinnedArray2D.h.


The documentation for this class was generated from the following file:
Trk::BinUtility::entry
size_t entry(const Amg::Vector3D &position, size_t ba=0) const
Bin from a 3D vector (already in binning frame)
Definition: BinUtility.h:136
Trk::BinnedArray2D::arrayObjectsNumber
unsigned int arrayObjectsNumber() const
Number of Entries in the Array.
Definition: BinnedArray2D.h:147
Trk::BinnedArray2D::object
T * object(const Amg::Vector2D &lp) const
Returns the pointer to the templated class object from the BinnedArray, it returns nullptr if not def...
Definition: BinnedArray2D.h:89
Trk::BinnedArray2D::arrayObjects
BinnedArraySpan< T *const > arrayObjects()
Return all objects of the Array non-const T.
Definition: BinnedArray2D.h:133
Trk::BinUtility::bins
size_t bins(size_t ba=0) const
Number of bins.
Definition: BinUtility.h:221
ParticleGun_EoverP_Config.mom
mom
Definition: ParticleGun_EoverP_Config.py:63
Trk::BinnedArray2D::BinnedArray2D
BinnedArray2D()=default
Trk::BinnedArray2D::m_arrayObjects
CxxUtils::CachedUniquePtr< std::vector< T * > > m_arrayObjects
binUtility for retrieving and filling the Array
Definition: BinnedArray2D.h:191
Trk::BinnedArray2D::m_binUtility
BinUtility m_binUtility
Definition: BinnedArray2D.h:193
Trk::BinUtility::inside
bool inside(const Amg::Vector3D &position) const
Check if bin is inside from Vector3D.
Definition: BinUtility.h:186
Trk::BinnedArray2D::createArrayCache
void createArrayCache() const
Definition: BinnedArray2D.h:156
python.LumiBlobConversion.pos
pos
Definition: LumiBlobConversion.py:18
Trk::BinnedArray2D::initialize
void initialize(const std::vector< std::pair< SharedObject< T >, Amg::Vector3D >> &tclassvector)
vector of pointers to the class T
Definition: BinnedArray2D.h:170
get
T * get(TKey *tobj)
get a TObject* from a TKey* (why can't a TObject be a TKey?)
Definition: hcg.cxx:127
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:126
Trk::BinnedArray2D::m_array
std::vector< std::vector< SharedObject< T > > > m_array
1D vector of cached not owning pointers to class T
Definition: BinnedArray2D.h:189
Trk::BinUtility::next
size_t next(const Amg::Vector3D &position, const Amg::Vector3D &direction, size_t ba=0) const
Bin from a 3D vector (already in binning frame)
Definition: BinUtility.h:145