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

#include <NavBinnedArray1D.h>

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

Public Member Functions

 NavBinnedArray1D ()
 Default Constructor - needed for inherited classes. More...
 
 NavBinnedArray1D (const std::vector< SharedObject< T >> &tclassvector, BinUtility *bingen, Amg::Transform3D *transform)
 Constructor with std::vector and a BinUtility - reference counted, will delete objects at the end, if this deletion should be turned off, the boolean deletion should be switched to false the global position is given by pointer and then deleted! More...
 
 NavBinnedArray1D (const NavBinnedArray1D &barr, std::vector< SharedObject< T >> &&vec, Amg::Transform3D &shift)
 Copy Constructor with shift. More...
 
 NavBinnedArray1D (const NavBinnedArray1D &barr)
 Copy Constructor - copies only pointers ! More...
 
NavBinnedArray1Doperator= (const NavBinnedArray1D &barr)
 Assignment operator. More...
 
NavBinnedArray1Dclone () const
 Implicit Constructor. More...
 
 ~NavBinnedArray1D ()
 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 &) 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...
 
Amg::Transform3Dtransform () const
 Return the transform. More...
 
void updateTransform (Amg::Transform3D &transform)
 Reposition. More...
 

Private Member Functions

void createArrayCache () const
 vector of pointers to the class T More...
 

Private Attributes

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...
 
SharedObject< BinUtilitym_binUtility
 
Amg::Transform3Dm_transf
 

Detailed Description

template<class T>
class Trk::NavBinnedArray1D< T >

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

For use within navigation objects, global coordinates/transform refer to the position within mother navigation object

Author
Andre.nosp@m.as.S.nosp@m.alzbu.nosp@m.rger.nosp@m.@cern.nosp@m..ch, Sarka.nosp@m..Tod.nosp@m.orova.nosp@m.@cer.nosp@m.n.ch
Christos Anastopoulos (Athena MT modifications)

Definition at line 35 of file NavBinnedArray1D.h.

Constructor & Destructor Documentation

◆ NavBinnedArray1D() [1/4]

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

Default Constructor - needed for inherited classes.

Definition at line 40 of file NavBinnedArray1D.h.

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

◆ NavBinnedArray1D() [2/4]

template<class T >
Trk::NavBinnedArray1D< T >::NavBinnedArray1D ( const std::vector< SharedObject< T >> &  tclassvector,
BinUtility bingen,
Amg::Transform3D transform 
)
inline

Constructor with std::vector and a BinUtility - reference counted, will delete objects at the end, if this deletion should be turned off, the boolean deletion should be switched to false the global position is given by pointer and then deleted!

Definition at line 52 of file NavBinnedArray1D.h.

55  : BinnedArray<T>()
56  , m_array{}
57  , m_arrayObjects(nullptr)
60  {
61  // prepare the binned Array // simplify as the array is ordered when defined
62  if (bingen) {
63  m_array = std::vector<SharedObject<T>>(tclassvector);
64  }
65  }

◆ NavBinnedArray1D() [3/4]

template<class T >
Trk::NavBinnedArray1D< T >::NavBinnedArray1D ( const NavBinnedArray1D< T > &  barr,
std::vector< SharedObject< T >> &&  vec,
Amg::Transform3D shift 
)
inline

Copy Constructor with shift.

Definition at line 68 of file NavBinnedArray1D.h.

71  : BinnedArray<T>()
72  , m_array(std::move(vec))
73  , m_arrayObjects{}
74  , m_binUtility(barr.m_binUtility)
75  , m_transf(new Amg::Transform3D(shift * (*barr.m_transf)))
76  {}

◆ NavBinnedArray1D() [4/4]

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

Copy Constructor - copies only pointers !

Definition at line 79 of file NavBinnedArray1D.h.

80  : BinnedArray<T>()
81  , m_array{}
82  , m_arrayObjects(nullptr)
83  , m_binUtility(barr.m_binUtility)
84  , m_transf(nullptr)
85  {
86  if (m_binUtility.get()) {
87  m_array = std::vector<SharedObject<T>>(m_binUtility.get()->bins(0));
88  for (size_t ient = 0; ient < m_binUtility.get()->bins(0); ++ient) {
89  m_array[ient] = (barr.m_array)[ient];
90  }
91  }
92  m_transf =
93  (barr.m_transf) ? new Amg::Transform3D(*(barr.m_transf)) : nullptr;
94  }

◆ ~NavBinnedArray1D()

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

Virtual Destructor.

Definition at line 121 of file NavBinnedArray1D.h.

121 { delete m_transf; }

Member Function Documentation

◆ arrayObjects() [1/2]

template<class T >
BinnedArraySpan<T* const> Trk::NavBinnedArray1D< T >::arrayObjects ( )
inlinevirtual

Return all objects of the Array non-const T.

Implements Trk::BinnedArray< T >.

Definition at line 178 of file NavBinnedArray1D.h.

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

◆ arrayObjects() [2/2]

template<class T >
BinnedArraySpan<T const * const> Trk::NavBinnedArray1D< T >::arrayObjects ( ) const
inlinevirtual

Return all objects of the Array const T.

Implements Trk::BinnedArray< T >.

Definition at line 185 of file NavBinnedArray1D.h.

186  {
188  return BinnedArraySpan<T const * const>(&*(m_arrayObjects->begin()), &*(m_arrayObjects->end()));
189  }

◆ arrayObjectsNumber()

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

Number of Entries in the Array.

Implements Trk::BinnedArray< T >.

Definition at line 192 of file NavBinnedArray1D.h.

192 { return arrayObjects().size(); }

◆ binUtility()

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

Return the BinUtility.

Implements Trk::BinnedArray< T >.

Definition at line 195 of file NavBinnedArray1D.h.

195 { return (m_binUtility.get()); }

◆ clone()

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

Implicit Constructor.

Implements Trk::BinnedArray< T >.

Definition at line 118 of file NavBinnedArray1D.h.

118 { return new NavBinnedArray1D(*this); }

◆ createArrayCache()

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

vector of pointers to the class T

Definition at line 209 of file NavBinnedArray1D.h.

◆ entryObject()

template<class T >
T* Trk::NavBinnedArray1D< T >::entryObject ( const Amg::Vector3D ) const
inlinevirtual

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

Implements Trk::BinnedArray< T >.

Definition at line 149 of file NavBinnedArray1D.h.

149 { return (m_array[0]).get(); }

◆ nextObject()

template<class T >
T* Trk::NavBinnedArray1D< 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 153 of file NavBinnedArray1D.h.

156  {
157  // transform into navig.coordinates
158  const Amg::Vector3D navGP((m_transf->inverse()) * gp);
159  const Amg::Vector3D navMom((m_transf->inverse()).linear() * mom);
160  // the bins
161  size_t firstBin = m_binUtility.get()->next(navGP, navMom, 0);
162  // use the information of the associated result
163  if (associatedResult) {
164  if (firstBin <= m_binUtility.get()->max(0)) {
165  return (m_array[firstBin]).get();
166  } else {
167  return nullptr;
168  }
169  }
170  // the associated result was 0 -> set to boundary
171  firstBin = (firstBin < m_binUtility.get()->bins(0))
172  ? firstBin
173  : m_binUtility.get()->max(0);
174  return (m_array[m_binUtility.get()->bin(navGP)]).get();
175  }

◆ object() [1/2]

template<class T >
T* Trk::NavBinnedArray1D< 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 126 of file NavBinnedArray1D.h.

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

◆ object() [2/2]

template<class T >
T* Trk::NavBinnedArray1D< 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 NavBinnedArray1D.h.

138  {
139  // transform into navig.coordinates
140  const Amg::Vector3D navGP((m_transf->inverse()) * gp);
141  if (m_binUtility.get()->inside(navGP)) {
142  return (m_array[m_binUtility.get()->bin(navGP)]).get();
143  }
144  return nullptr;
145  }

◆ operator=()

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

Assignment operator.

Definition at line 97 of file NavBinnedArray1D.h.

98  {
99  if (this != &barr) {
100  m_arrayObjects.release();
101  delete m_transf;
102  // now refill
103  m_binUtility = barr.m_binUtility;
104  // --------------------------------------------------------------------------
105  if (m_binUtility.get()) {
106  m_array = std::vector<SharedObject<T>>(m_binUtility.get()->bins(0));
107  for (size_t ient = 0; ient < m_binUtility.get()->bins(0); ++ient) {
108  m_array[ient] = (barr.m_array)[ient];
109  }
110  }
111  m_transf =
112  (barr.m_transf) ? new Amg::Transform3D(*barr.m_transf) : nullptr;
113  }
114  return *this;
115  }

◆ transform()

template<class T >
Amg::Transform3D* Trk::NavBinnedArray1D< T >::transform ( ) const
inline

Return the transform.

Definition at line 198 of file NavBinnedArray1D.h.

198 { return (m_transf); }

◆ updateTransform()

template<class T >
void Trk::NavBinnedArray1D< T >::updateTransform ( Amg::Transform3D transform)
inline

Reposition.

Definition at line 201 of file NavBinnedArray1D.h.

202  {
205  delete tr;
206  }

Member Data Documentation

◆ m_array

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

forced 1D vector of pointers to class T

Definition at line 222 of file NavBinnedArray1D.h.

◆ m_arrayObjects

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

binUtility for retrieving and filling the Array

Definition at line 224 of file NavBinnedArray1D.h.

◆ m_binUtility

template<class T >
SharedObject<BinUtility> Trk::NavBinnedArray1D< T >::m_binUtility
private

Definition at line 226 of file NavBinnedArray1D.h.

◆ m_transf

template<class T >
Amg::Transform3D* Trk::NavBinnedArray1D< T >::m_transf
private

Definition at line 228 of file NavBinnedArray1D.h.


The documentation for this class was generated from the following file:
Trk::NavBinnedArray1D::m_binUtility
SharedObject< BinUtility > m_binUtility
Definition: NavBinnedArray1D.h:226
vec
std::vector< size_t > vec
Definition: CombinationsGeneratorTest.cxx:12
SharedObject
Trk::NavBinnedArray1D::m_transf
Amg::Transform3D * m_transf
Definition: NavBinnedArray1D.h:228
Trk::NavBinnedArray1D::m_arrayObjects
CxxUtils::CachedUniquePtr< std::vector< T * > > m_arrayObjects
binUtility for retrieving and filling the Array
Definition: NavBinnedArray1D.h:224
ParticleGun_EoverP_Config.mom
mom
Definition: ParticleGun_EoverP_Config.py:63
Trk::NavBinnedArray1D::transform
Amg::Transform3D * transform() const
Return the transform.
Definition: NavBinnedArray1D.h:198
Amg::Transform3D
Eigen::Affine3d Transform3D
Definition: GeoPrimitives.h:46
Trk::NavBinnedArray1D::NavBinnedArray1D
NavBinnedArray1D()
Default Constructor - needed for inherited classes.
Definition: NavBinnedArray1D.h:40
Trk::NavBinnedArray1D::m_array
std::vector< SharedObject< T > > m_array
forced 1D vector of pointers to class T
Definition: NavBinnedArray1D.h:222
Amg::Vector3D
Eigen::Matrix< double, 3, 1 > Vector3D
Definition: GeoPrimitives.h:47
Trk::NavBinnedArray1D::arrayObjects
BinnedArraySpan< T *const > arrayObjects()
Return all objects of the Array non-const T.
Definition: NavBinnedArray1D.h:178
get
T * get(TKey *tobj)
get a TObject* from a TKey* (why can't a TObject be a TKey?)
Definition: hcg.cxx:127
Trk::NavBinnedArray1D::createArrayCache
void createArrayCache() const
vector of pointers to the class T
Definition: NavBinnedArray1D.h:209