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

#include <CompactBinnedArray2D.h>

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

Public Member Functions

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

Private Attributes

std::vector< std::vector< size_t > > m_array
 vector of indices to objects More...
 
std::vector< T * > m_arrayObjects
 objects More...
 
const BinUtilitym_binUtility
 binUtility More...
 
std::vector< BinUtility * > m_buVec
 vector of bin utilities for 2nd dim More...
 

Detailed Description

template<class T>
class Trk::CompactBinnedArray2D< T >

2-dimensional binned array

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

Definition at line 31 of file CompactBinnedArray2D.h.

Constructor & Destructor Documentation

◆ CompactBinnedArray2D() [1/3]

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

Default Constructor - needed for inherited classes.

Definition at line 36 of file CompactBinnedArray2D.h.

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

◆ CompactBinnedArray2D() [2/3]

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

Constructor with std::vector and a BinUtility.

Definition at line 42 of file CompactBinnedArray2D.h.

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

◆ CompactBinnedArray2D() [3/3]

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

Copy Constructor - copies only pointers !

Definition at line 74 of file CompactBinnedArray2D.h.

75  : CompactBinnedArray<T>()
76  , m_array()
77  , m_arrayObjects()
78  , m_binUtility(nullptr)
79  , m_buVec()
80  {
81  m_binUtility = (barr.m_binUtility) ? barr.m_binUtility->clone() : 0;
82 
83  m_array = barr.m_array;
84  m_arrayObjects = barr.m_arrayObjects;
85  m_buVec = barr.m_buVec;
86  }

◆ ~CompactBinnedArray2D()

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

Virtual Destructor.

Definition at line 119 of file CompactBinnedArray2D.h.

120  {
121  delete m_binUtility;
122  for (unsigned int i = 0; i < m_buVec.size(); i++)
123  delete m_buVec[i];
124  }

Member Function Documentation

◆ arrayObjects() [1/2]

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

Return all objects of the Array.

Implements Trk::BinnedArray< T >.

Definition at line 192 of file CompactBinnedArray2D.h.

193  {
194  return BinnedArraySpan<T* const>(m_arrayObjects.data(),
195  m_arrayObjects.data() + m_arrayObjects.size());
196  }

◆ arrayObjects() [2/2]

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

Return all objects of the Array const T.

Implements Trk::BinnedArray< T >.

Definition at line 200 of file CompactBinnedArray2D.h.

201  {
202  return BinnedArraySpan<const T* const>(m_arrayObjects.data(),
203  m_arrayObjects.data() + m_arrayObjects.size());
204  }

◆ arrayObjectsNumber()

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

Number of Entries in the Array.

Implements Trk::BinnedArray< T >.

Definition at line 207 of file CompactBinnedArray2D.h.

207 { return m_arrayObjects.size(); }

◆ binUtility()

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

Return the BinUtility.

Implements Trk::BinnedArray< T >.

Definition at line 210 of file CompactBinnedArray2D.h.

210 { return (m_binUtility); }

◆ clone() [1/2]

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

Implicit Constructor.

Implements Trk::CompactBinnedArray< T >.

Definition at line 105 of file CompactBinnedArray2D.h.

106  {
107  return new CompactBinnedArray2D(
109  }

◆ clone() [2/2]

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

Implements Trk::CompactBinnedArray< T >.

Definition at line 111 of file CompactBinnedArray2D.h.

112  {
113  assert(ptrs.size() == m_arrayObjects.size());
114  return new CompactBinnedArray2D(
115  ptrs, m_array, m_binUtility->clone(), m_buVec);
116  }

◆ entryObject()

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

155  {
156  if (m_binUtility) {
157  size_t bin = m_binUtility->bin(gp);
158  size_t biNext = m_binUtility->entry(gp, 0);
159  return (m_arrayObjects[m_array[biNext][m_buVec[bin]->entry(gp, 0)]]);
160  }
161  return nullptr;
162  }

◆ layerBin()

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

Return the layer bin.

Implements Trk::CompactBinnedArray< T >.

Definition at line 219 of file CompactBinnedArray2D.h.

220  {
221  return (layerBinUtility(pos)->bin(pos));
222  }

◆ layerBinUtility()

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

Return the BinUtility.

Implements Trk::CompactBinnedArray< T >.

Definition at line 213 of file CompactBinnedArray2D.h.

214  {
215  return (m_buVec[m_binUtility->bin(pos)]);
216  }

◆ nextObject()

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

169  {
170  if (!m_binUtility)
171  return nullptr;
172  // search in layer utility only
173  size_t bin = m_binUtility->bin(gp, 0);
174  size_t binSub = m_buVec[bin]->next(gp, mom, 0);
175  if (associatedResult) {
176  return m_arrayObjects[m_array[bin][binSub]];
177  }
178  // evaluate distance
179  std::pair<int, float> ds = m_binUtility->distanceToNext(gp, mom, 0);
180  std::pair<int, float> dl = m_buVec[bin]->distanceToNext(gp, mom, 0);
181  // the bins
182  if (dl.second < ds.second)
183  return m_arrayObjects[m_array[bin][binSub]];
184 
185  bin = m_binUtility->next(gp, mom, 0);
186  Amg::Vector3D probe = gp + (ds.second) * mom.normalized();
187  binSub = m_buVec[bin]->bin(probe, 0);
188  return m_arrayObjects[m_array[bin][binSub]];
189  }

◆ object() [1/2]

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

130  {
131  if (m_binUtility->inside(lp)) {
132  size_t bin = m_binUtility->bin(lp, 0);
133  if (m_buVec[bin]->inside(lp))
134  return m_arrayObjects[m_array[bin][m_buVec[bin]->bin(lp, 0)]];
135  }
136  return nullptr;
137  }

◆ object() [2/2]

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

143  {
144  if (m_binUtility) {
145  size_t bin = m_binUtility->bin(gp);
146  size_t index = m_array[bin][m_buVec[bin]->bin(gp, 0)];
147  return m_arrayObjects[index];
148  }
149  return nullptr;
150  }

◆ operator=()

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

Assignment operator.

Definition at line 88 of file CompactBinnedArray2D.h.

89  {
90  if (this != &barr) {
91 
92  delete m_binUtility;
93  // now refill
94  m_binUtility = (barr.m_binUtility) ? barr.m_binUtility->clone() : 0;
95  // --------------------------------------------------------------------------
96  if (m_binUtility) {
97  m_array = std::vector<std::vector<size_t>>((barr.m_array));
98  m_arrayObjects = std::vector<T*>((barr.m_arrayObjects));
99  m_buVec = std::vector<Trk::BinUtility*>((barr.m_buVec));
100  }
101  }
102  return *this;
103  }

Member Data Documentation

◆ m_array

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

vector of indices to objects

Definition at line 225 of file CompactBinnedArray2D.h.

◆ m_arrayObjects

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

objects

Definition at line 226 of file CompactBinnedArray2D.h.

◆ m_binUtility

template<class T >
const BinUtility* Trk::CompactBinnedArray2D< T >::m_binUtility
private

binUtility

Definition at line 227 of file CompactBinnedArray2D.h.

◆ m_buVec

template<class T >
std::vector<BinUtility*> Trk::CompactBinnedArray2D< T >::m_buVec
private

vector of bin utilities for 2nd dim

Definition at line 228 of file CompactBinnedArray2D.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
checkxAOD.ds
ds
Definition: Tools/PyUtils/bin/checkxAOD.py:260
TestSUSYToolsAlg.dl
dl
Definition: TestSUSYToolsAlg.py:81
Trk::CompactBinnedArray2D::m_binUtility
const BinUtility * m_binUtility
binUtility
Definition: CompactBinnedArray2D.h:227
index
Definition: index.py:1
Trk::CompactBinnedArray2D::m_buVec
std::vector< BinUtility * > m_buVec
vector of bin utilities for 2nd dim
Definition: CompactBinnedArray2D.h:228
Trk::BinUtility::distanceToNext
std::pair< size_t, float > distanceToNext(const Amg::Vector3D &position, const Amg::Vector3D &direction, size_t ba=0) const
Distance estimate to next bin
Definition: BinUtility.h:161
bin
Definition: BinsDiffFromStripMedian.h:43
ParticleGun_EoverP_Config.mom
mom
Definition: ParticleGun_EoverP_Config.py:63
Trk::CompactBinnedArray2D::layerBinUtility
const BinUtility * layerBinUtility(const Amg::Vector3D &pos) const
Return the BinUtility.
Definition: CompactBinnedArray2D.h:213
lumiFormat.i
int i
Definition: lumiFormat.py:85
Trk::CompactBinnedArray2D::m_arrayObjects
std::vector< T * > m_arrayObjects
objects
Definition: CompactBinnedArray2D.h:226
Trk::CompactBinnedArray2D::CompactBinnedArray2D
CompactBinnedArray2D()
Default Constructor - needed for inherited classes.
Definition: CompactBinnedArray2D.h:36
GetAllXsec.entry
list entry
Definition: GetAllXsec.py:132
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
Amg::Vector3D
Eigen::Matrix< double, 3, 1 > Vector3D
Definition: GeoPrimitives.h:47
python.LumiBlobConversion.pos
pos
Definition: LumiBlobConversion.py:18
Trk::inside
@ inside
Definition: PropDirection.h:29
DeMoScan.index
string index
Definition: DeMoScan.py:364
Trk::BinUtility::clone
BinUtility * clone() const
Implizit Constructor.
Definition: BinUtility.h:130
Trk::CompactBinnedArray2D::m_array
std::vector< std::vector< size_t > > m_array
vector of indices to objects
Definition: CompactBinnedArray2D.h:225
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