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

#include <CompactBinnedArray1D.h>

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

Public Member Functions

 CompactBinnedArray1D ()
 Default Constructor - needed for inherited classes. More...
 
 CompactBinnedArray1D (const std::vector< T * > &tclassvector, const std::vector< size_t > &indexvector, BinUtility *bingen)
 Constructor with std::vector and a BinUtility. More...
 
 CompactBinnedArray1D (const CompactBinnedArray1D &barr)
 Copy Constructor - copies only pointers ! More...
 
CompactBinnedArray1Doperator= (const CompactBinnedArray1D &barr)
 Assignment operator. More...
 
CompactBinnedArray1Dclone () const
 Implicit Constructor. More...
 
CompactBinnedArray1Dclone (const std::vector< T * > &ptrs) const
 
 ~CompactBinnedArray1D ()
 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 &gp) 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...
 
const BinUtilitylayerBinUtility (const Amg::Vector3D &) const
 Return the BinUtility. More...
 
size_t layerBin (const Amg::Vector3D &pos) const
 Return the layer bin. More...
 

Private Attributes

std::vector< size_t > m_array
 vector of indices to objects More...
 
std::vector< T * > m_arrayObjects
 objects More...
 
BinUtilitym_binUtility
 binUtility More...
 

Detailed Description

template<class T>
class Trk::CompactBinnedArray1D< T >

1-dimensional binned arry based on a sorting given by the BinUtitlity.

Author
sarka.nosp@m..tod.nosp@m.orova.nosp@m.@cer.nosp@m.n.ch
Christos Anastopoulos (Athena MT modifications)

Definition at line 32 of file CompactBinnedArray1D.h.

Constructor & Destructor Documentation

◆ CompactBinnedArray1D() [1/3]

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

Default Constructor - needed for inherited classes.

Definition at line 37 of file CompactBinnedArray1D.h.

38  : CompactBinnedArray<T>()
39  , m_binUtility(nullptr)
40  {}

◆ CompactBinnedArray1D() [2/3]

template<class T >
Trk::CompactBinnedArray1D< T >::CompactBinnedArray1D ( const std::vector< T * > &  tclassvector,
const std::vector< size_t > &  indexvector,
BinUtility bingen 
)
inline

Constructor with std::vector and a BinUtility.

Definition at line 43 of file CompactBinnedArray1D.h.

46  : CompactBinnedArray<T>()
47  , m_array(indexvector)
48  , m_arrayObjects(tclassvector)
49  , m_binUtility(bingen)
50  {
51  // check compatibility
52  // size of the index vector must correspond to the number of bins in the
53  // BinUtility
54  if (indexvector.size() != bingen->bins())
55  std::cout << " problem in construction of CompactBinnedArray1D: number "
56  "of indexes not compatible with BinUtility:"
57  << indexvector.size() << "!=" << bingen->bins() << std::endl;
58  // maximal index must stay within the range of available objects
59  unsigned int iMax = 0;
60  for (unsigned int i = 0; i < indexvector.size(); i++)
61  if (indexvector[i] > iMax)
62  iMax = indexvector[i];
63  if (iMax > tclassvector.size() - 1)
64  std::cout
65  << " problem in construction of CompactBinnedArray1D:runaway index:"
66  << iMax << "," << tclassvector.size() << std::endl;
67  }

◆ CompactBinnedArray1D() [3/3]

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

Copy Constructor - copies only pointers !

Definition at line 70 of file CompactBinnedArray1D.h.

71  : CompactBinnedArray<T>()
72  , m_binUtility(nullptr)
73  {
74  m_binUtility = (barr.m_binUtility) ? barr.m_binUtility->clone() : 0;
75 
76  m_array = barr.m_array;
77  m_arrayObjects = barr.m_arrayObjects;
78  }

◆ ~CompactBinnedArray1D()

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

Virtual Destructor.

Definition at line 109 of file CompactBinnedArray1D.h.

109 { delete m_binUtility; }

Member Function Documentation

◆ arrayObjects() [1/2]

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

Return all objects of the Array non const T.

Implements Trk::BinnedArray< T >.

Definition at line 155 of file CompactBinnedArray1D.h.

156  {
157  return BinnedArraySpan<T* const>(m_arrayObjects.data(),
158  m_arrayObjects.data() + m_arrayObjects.size());
159  }

◆ arrayObjects() [2/2]

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

Return all objects of the Array const T.

Implements Trk::BinnedArray< T >.

Definition at line 162 of file CompactBinnedArray1D.h.

163  {
164  return BinnedArraySpan<T const * const>(m_arrayObjects.data(),
165  m_arrayObjects.data() + m_arrayObjects.size());
166  }

◆ arrayObjectsNumber()

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

Number of Entries in the Array.

Implements Trk::BinnedArray< T >.

Definition at line 169 of file CompactBinnedArray1D.h.

169 { return m_arrayObjects.size(); }

◆ binUtility()

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

Return the BinUtility.

Implements Trk::BinnedArray< T >.

Definition at line 172 of file CompactBinnedArray1D.h.

172 { return (m_binUtility); }

◆ clone() [1/2]

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

Implicit Constructor.

Implements Trk::CompactBinnedArray< T >.

Definition at line 96 of file CompactBinnedArray1D.h.

97  {
98  return new CompactBinnedArray1D(
100  }

◆ clone() [2/2]

template<class T >
CompactBinnedArray1D* Trk::CompactBinnedArray1D< T >::clone ( const std::vector< T * > &  ptrs) const
inlinevirtual

Implements Trk::CompactBinnedArray< T >.

Definition at line 102 of file CompactBinnedArray1D.h.

103  {
104  assert(ptrs.size() == m_arrayObjects.size());
105  return new CompactBinnedArray1D(ptrs, m_array, m_binUtility->clone());
106  }

◆ entryObject()

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

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

Implements Trk::BinnedArray< T >.

Definition at line 133 of file CompactBinnedArray1D.h.

134  {
135  if (m_binUtility)
136  return (m_arrayObjects[m_array[m_binUtility->entry(gp, 0)]]);
137  return nullptr;
138  }

◆ layerBin()

template<class T >
size_t Trk::CompactBinnedArray1D< T >::layerBin ( const Amg::Vector3D pos) const
inlinevirtual

Return the layer bin.

Implements Trk::CompactBinnedArray< T >.

Definition at line 181 of file CompactBinnedArray1D.h.

182  {
183  return (m_binUtility->bin(pos));
184  }

◆ layerBinUtility()

template<class T >
const BinUtility* Trk::CompactBinnedArray1D< T >::layerBinUtility ( const Amg::Vector3D ) const
inlinevirtual

Return the BinUtility.

Implements Trk::CompactBinnedArray< T >.

Definition at line 175 of file CompactBinnedArray1D.h.

176  {
177  return (m_binUtility);
178  }

◆ nextObject()

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

145  {
146  if (!m_binUtility)
147  return nullptr;
148  // the bins
149  size_t bin = associatedResult ? m_binUtility->bin(gp, 0)
150  : m_binUtility->next(gp, mom, 0);
151  return m_arrayObjects[m_array[bin]];
152  }

◆ object() [1/2]

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

115  {
116  if (m_binUtility->inside(lp))
117  return m_arrayObjects[m_array[m_binUtility->bin(lp, 0)]];
118  return nullptr;
119  }

◆ object() [2/2]

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

125  {
126  if (m_binUtility)
127  return m_arrayObjects[m_array[m_binUtility->bin(gp, 0)]];
128  return nullptr;
129  }

◆ operator=()

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

Assignment operator.

Definition at line 80 of file CompactBinnedArray1D.h.

81  {
82  if (this != &barr) {
83 
84  delete m_binUtility;
85  // now refill
86  m_binUtility = (barr.m_binUtility) ? barr.m_binUtility->clone() : 0;
87  // --------------------------------------------------------------------------
88  if (m_binUtility) {
89  m_array = barr.m_array;
90  m_arrayObjects = barr.m_arrayObjects;
91  }
92  }
93  return *this;
94  }

Member Data Documentation

◆ m_array

template<class T >
std::vector<size_t> Trk::CompactBinnedArray1D< T >::m_array
private

vector of indices to objects

Definition at line 187 of file CompactBinnedArray1D.h.

◆ m_arrayObjects

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

objects

Definition at line 188 of file CompactBinnedArray1D.h.

◆ m_binUtility

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

binUtility

Definition at line 189 of file CompactBinnedArray1D.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
Trk::CompactBinnedArray1D::m_binUtility
BinUtility * m_binUtility
binUtility
Definition: CompactBinnedArray1D.h:189
bin
Definition: BinsDiffFromStripMedian.h:43
ParticleGun_EoverP_Config.mom
mom
Definition: ParticleGun_EoverP_Config.py:63
lumiFormat.i
int i
Definition: lumiFormat.py:85
Trk::CompactBinnedArray1D::m_arrayObjects
std::vector< T * > m_arrayObjects
objects
Definition: CompactBinnedArray1D.h:188
Trk::CompactBinnedArray1D::CompactBinnedArray1D
CompactBinnedArray1D()
Default Constructor - needed for inherited classes.
Definition: CompactBinnedArray1D.h:37
Trk::BinUtility::inside
bool inside(const Amg::Vector3D &position) const
Check if bin is inside from Vector3D.
Definition: BinUtility.h:190
plotBeamSpotVxVal.bin
int bin
Definition: plotBeamSpotVxVal.py:83
Trk::CompactBinnedArray1D::m_array
std::vector< size_t > m_array
vector of indices to objects
Definition: CompactBinnedArray1D.h:187
python.LumiBlobConversion.pos
pos
Definition: LumiBlobConversion.py:18
Trk::BinUtility::clone
BinUtility * clone() const
Implizit Constructor.
Definition: BinUtility.h:130
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::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