ATLAS Offline Software
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 Constructor - needed for inherited classes. More...
 
 BinnedArray2D (const std::vector< std::pair< SharedObject< T >, Amg::Vector3D >> &tclassvector, BinUtility *bingen)
 Constructor with std::vector and a BinUtility. More...
 
 BinnedArray2D (const BinnedArray2D &barr)
 Copy Constructor - copies only pointers ! More...
 
BinnedArray2Doperator= (const BinnedArray2D &barr)
 Assignment operator. More...
 
BinnedArray2Dclone () const
 Implizit Constructor. More...
 
 ~BinnedArray2D ()
 Virtual Destructor. More...
 
T * object (const Amg::Vector2D &lp) const
 Returns the pointer to the templated class object from the BinnedArray, it returns 0 if not defined;. More...
 
T * object (const Amg::Vector3D &gp) const
 Returns the pointer to the templated class object from the BinnedArray it returns 0 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
 vector of pointers to the class T More...
 

Private Attributes

std::vector< std::vector< SharedObject< T > > > m_array
 forced 1D vector of pointers to class T More...
 
CxxUtils::CachedUniquePtr< std::vector< T * > > m_arrayObjects
 binUtility for retrieving and filling the Array More...
 
BinUtilitym_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/3]

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

Default Constructor - needed for inherited classes.

Definition at line 41 of file BinnedArray2D.h.

42  : BinnedArray<T>()
43  , m_array{}
44  , m_arrayObjects(nullptr)
45  , m_binUtility(nullptr)
46  {}

◆ BinnedArray2D() [2/3]

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

Constructor with std::vector and a BinUtility.

Definition at line 49 of file BinnedArray2D.h.

52  : BinnedArray<T>()
53  , m_array{}
54  , m_arrayObjects(nullptr)
55  , m_binUtility(bingen)
56  {
57 
58  if (bingen) {
59  m_array = std::vector<std::vector<SharedObject<T>>>(bingen->bins(1));
60  for (size_t i = 0; i < bingen->bins(1); ++i) {
61  m_array[i] = std::vector<SharedObject<T>>(bingen->bins(0));
62  }
63  // fill the Volume vector into the array
64  size_t vecsize = tclassvector.size();
65  for (size_t ivec = 0; ivec < vecsize; ++ivec) {
66  const Amg::Vector3D currentGlobal(((tclassvector[ivec]).second));
67  if (bingen->inside(currentGlobal)) {
68  std::vector<SharedObject<T>>& curVec =
69  m_array[bingen->bin(currentGlobal, 1)];
70 
71  curVec[bingen->bin(currentGlobal, 0)] = ((tclassvector)[ivec]).first;
72  } else {
73  throw GaudiException(
74  "BinnedArray2D", "Object outside bounds", StatusCode::FAILURE);
75  }
76  }
77  }
78  }

◆ BinnedArray2D() [3/3]

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

Copy Constructor - copies only pointers !

Definition at line 81 of file BinnedArray2D.h.

82  : BinnedArray<T>()
83  , m_array{}
84  , m_arrayObjects(nullptr)
85  , m_binUtility(nullptr)
86  {
87  m_binUtility = (barr.m_binUtility) ? barr.m_binUtility->clone() : nullptr;
88  // copy over
89  m_array = std::vector<std::vector<SharedObject<T>>>(barr.m_array.size());
90  for (size_t ihl = 0; ihl < barr.m_array.size(); ++ihl) {
91  m_array[ihl] = std::vector<SharedObject<T>>((barr.m_array[0]).size());
92  for (size_t ill = 0; ill < (barr.m_array[0]).size(); ++ill) {
93  m_array[ihl][ill] = (barr.m_array)[ihl][ill];
94  }
95  }
96  }

◆ ~BinnedArray2D()

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

Virtual Destructor.

Definition at line 120 of file BinnedArray2D.h.

120 { delete 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 172 of file BinnedArray2D.h.

173  {
175  return BinnedArraySpan<T* const>(&*(m_arrayObjects->begin()), &*(m_arrayObjects->end()));
176  }

◆ 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 179 of file BinnedArray2D.h.

180  {
182  return BinnedArraySpan<T const * const>(&*(m_arrayObjects->begin()), &*(m_arrayObjects->end()));
183  }

◆ 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 186 of file BinnedArray2D.h.

187  {
188  return (m_array.size() * (m_array[0]).size());
189  }

◆ binUtility()

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

Return the BinUtility.

Implements Trk::BinnedArray< T >.

Definition at line 192 of file BinnedArray2D.h.

192 { return (m_binUtility); }

◆ clone()

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

Implizit Constructor.

Implements Trk::BinnedArray< T >.

Definition at line 117 of file BinnedArray2D.h.

117 { return new BinnedArray2D(*this); }

◆ createArrayCache()

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

vector of pointers to the class T

Definition at line 195 of file BinnedArray2D.h.

◆ 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 148 of file BinnedArray2D.h.

149  {
150  return (m_array[m_binUtility->entry(pos, 1)][m_binUtility->entry(pos, 0)])
151  .get();
152  }

◆ 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 156 of file BinnedArray2D.h.

159  {
160  // direct access to associated one
161  if (associatedResult)
162  return object(gp);
163  size_t nextFirst = m_binUtility->next(gp, mom, 0);
164  size_t nextSecond = m_binUtility->next(gp, mom, 1);
165 
166  return (nextFirst > 0 && nextSecond > 0)
167  ? (m_array[nextSecond][nextFirst]).get()
168  : nullptr;
169  }

◆ 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 0 if not defined;.

Implements Trk::BinnedArray< T >.

Definition at line 125 of file BinnedArray2D.h.

126  {
127  if (m_binUtility->inside(lp)) {
128  return (m_array[m_binUtility->bin(lp, 1)][m_binUtility->bin(lp, 0)])
129  .get();
130  }
131  return nullptr;
132  }

◆ 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 0 if not defined;.

Implements Trk::BinnedArray< T >.

Definition at line 137 of file BinnedArray2D.h.

138  {
139  if (m_binUtility->inside(gp)) {
140  return (m_array[m_binUtility->bin(gp, 1)][m_binUtility->bin(gp, 0)])
141  .get();
142  }
143  return nullptr;
144  }

◆ operator=()

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

Assignment operator.

Definition at line 98 of file BinnedArray2D.h.

99  {
100  if (this != &barr) {
101  m_arrayObjects.release();
102  delete m_binUtility;
103  // now refill
104  m_binUtility = (barr.m_binUtility) ? barr.m_binUtility->clone() : nullptr;
105  // assign over
106  m_array = std::vector<std::vector<SharedObject<T>>>(barr.m_array.size());
107  for (size_t ihl = 0; ihl < barr.m_array.size(); ++ihl) {
108  m_array[ihl] = std::vector<SharedObject<T>>((barr.m_array[0]).size());
109  for (size_t ill = 0; ill < ((barr.m_array)[0]).size(); ++ill) {
110  m_array[ihl][ill] = (barr.m_array)[ihl][ill];
111  }
112  }
113  }
114  return *this;
115  }

Member Data Documentation

◆ m_array

template<class T >
std::vector<std::vector<SharedObject<T> > > Trk::BinnedArray2D< T >::m_array
private

forced 1D vector of pointers to class T

Definition at line 214 of file BinnedArray2D.h.

◆ m_arrayObjects

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

binUtility for retrieving and filling the Array

Definition at line 216 of file BinnedArray2D.h.

◆ m_binUtility

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

Definition at line 218 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:145
python.SystemOfUnits.second
int second
Definition: SystemOfUnits.py:120
Trk::BinnedArray2D::object
T * object(const Amg::Vector2D &lp) const
Returns the pointer to the templated class object from the BinnedArray, it returns 0 if not defined;.
Definition: BinnedArray2D.h:125
Trk::BinnedArray2D::BinnedArray2D
BinnedArray2D()
Default Constructor - needed for inherited classes.
Definition: BinnedArray2D.h:41
python.setupRTTAlg.size
int size
Definition: setupRTTAlg.py:39
ParticleGun_EoverP_Config.mom
mom
Definition: ParticleGun_EoverP_Config.py:63
lumiFormat.i
int i
Definition: lumiFormat.py:85
Trk::BinnedArray2D::m_arrayObjects
CxxUtils::CachedUniquePtr< std::vector< T * > > m_arrayObjects
binUtility for retrieving and filling the Array
Definition: BinnedArray2D.h:216
Trk::BinnedArray2D::m_binUtility
BinUtility * m_binUtility
Definition: BinnedArray2D.h:218
Trk::BinUtility::inside
bool inside(const Amg::Vector3D &position) const
Check if bin is inside from Vector3D.
Definition: BinUtility.h:190
Trk::BinnedArray2D::createArrayCache
void createArrayCache() const
vector of pointers to the class T
Definition: BinnedArray2D.h:195
Amg::Vector3D
Eigen::Matrix< double, 3, 1 > Vector3D
Definition: GeoPrimitives.h:47
python.LumiBlobConversion.pos
pos
Definition: LumiBlobConversion.py:18
Trk::BinUtility::clone
BinUtility * clone() const
Implizit Constructor.
Definition: BinUtility.h:130
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:136
CxxUtils::ivec
vec_fb< typename boost::int_t< sizeof(T) *8 >::exact, N > ivec
Definition: vec_fb.h:53
Trk::BinnedArray2D::m_array
std::vector< std::vector< SharedObject< T > > > m_array
forced 1D vector of pointers to class T
Definition: BinnedArray2D.h:214
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:153