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

#include <BinnedArray1D1D1D.h>

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

Public Member Functions

 BinnedArray1D1D1D ()
 Default Constructor - needed for inherited classes. More...
 
 BinnedArray1D1D1D (const std::vector< std::pair< SharedObject< T >, Amg::Vector3D >> &tclassvector, BinUtility *binUtil1, BinUtility *binUtil2, std::vector< std::vector< BinUtility * >> *binUtilVec)
 Constructor with std::vector and a BinUtility. More...
 
 BinnedArray1D1D1D (const BinnedArray1D1D1D &barr)
 Copy Constructor - copies only pointers! More...
 
BinnedArray1D1D1Doperator= (const BinnedArray1D1D1D &barr)
 Assignment operator. More...
 
BinnedArray1D1D1Dclone () const
 Implicit Constructor. More...
 
 ~BinnedArray1D1D1D ()
 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 &, const Amg::Vector3D &, bool) const
 Returns the pointer to the templated class object from the BinnedArray dummy for multidimensional arrays
More...
 
BinnedArraySpan< T *constarrayObjects ()
 Return all objects of the Array 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 - returns the first binUtility in this case. More...
 

Private Member Functions

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

Private Attributes

std::vector< std::vector< std::vector< SharedObject< T > > > > m_array
 forced 1D vector of pointers to class T More...
 
CxxUtils::CachedUniquePtr< std::vector< T * > > m_arrayObjects
 
BinUtilitym_binUtil1
 binUtility for retrieving and filling the Array More...
 
BinUtilitym_binUtil2
 binUtility for retrieving and filling the Array More...
 
std::vector< std::vector< BinUtility * > > * m_binUtilArray
 

Detailed Description

template<class T>
class Trk::BinnedArray1D1D1D< T >

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

dedicated for 3-dim (non-eq) binning ; allows variable binning in 1 coordinate

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

Definition at line 38 of file BinnedArray1D1D1D.h.

Constructor & Destructor Documentation

◆ BinnedArray1D1D1D() [1/3]

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

Default Constructor - needed for inherited classes.

Definition at line 43 of file BinnedArray1D1D1D.h.

44  : BinnedArray<T>()
45  , m_array{}
46  , m_arrayObjects(nullptr)
47  , m_binUtil1(nullptr)
48  , m_binUtil2(nullptr)
49  , m_binUtilArray(nullptr)
50  {}

◆ BinnedArray1D1D1D() [2/3]

template<class T >
Trk::BinnedArray1D1D1D< T >::BinnedArray1D1D1D ( const std::vector< std::pair< SharedObject< T >, Amg::Vector3D >> &  tclassvector,
BinUtility binUtil1,
BinUtility binUtil2,
std::vector< std::vector< BinUtility * >> *  binUtilVec 
)
inline

Constructor with std::vector and a BinUtility.

Definition at line 53 of file BinnedArray1D1D1D.h.

58  : BinnedArray<T>()
59  , m_array{}
60  , m_arrayObjects(nullptr)
61  , m_binUtil1(binUtil1)
62  , m_binUtil2(binUtil2)
63  , m_binUtilArray(binUtilVec)
64  {
65  // prepare the binned Array
66  if (!binUtil1 || !binUtil2 || !binUtilVec) {
67  throw std::logic_error("Invalid BinUtilities");
68  }
69 
70  {
71  int v1Size = binUtil1->bins();
72  int v2Size = binUtil2->bins();
73  m_array = std::vector<std::vector<std::vector<SharedObject<T>>>>(v1Size);
74  for (int i = 0; i < v1Size; ++i) {
75  m_array[i] = std::vector<std::vector<SharedObject<T>>>(v2Size);
76  for (int j = 0; j < v2Size; ++j) {
77  m_array[i][j] =
78  std::vector<SharedObject<T>>((*binUtilVec)[i][j]->bins());
79  }
80  }
81  }
82 
83  // fill the Volume vector into the array
84  int vecsize(tclassvector.size());
85  for (int ivec = 0; ivec < vecsize; ++ivec) {
86  Amg::Vector3D currentGlobal((tclassvector[ivec]).second);
87  if (binUtil1->inside(currentGlobal) && binUtil2->inside(currentGlobal)) {
88  int bin1 = binUtil1->bin(currentGlobal);
89  int bin2 = binUtil2->bin(currentGlobal);
90  assert((*binUtilVec)[bin1][bin2]);
91  int bin3 = (*binUtilVec)[bin1][bin2]->bin(currentGlobal);
92  std::vector<std::vector<SharedObject<T>>>& currArr = m_array[bin1];
93  std::vector<SharedObject<T>>& curVec = currArr[bin2];
94  curVec[bin3] = ((tclassvector)[ivec]).first;
95  } else
96  throw GaudiException(
97  "BinnedArray1D1D1D", "Object outside bounds", StatusCode::FAILURE);
98  }
99  }

◆ BinnedArray1D1D1D() [3/3]

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

Copy Constructor - copies only pointers!

Definition at line 102 of file BinnedArray1D1D1D.h.

103  : BinnedArray<T>()
104  , m_array{}
105  , m_arrayObjects(nullptr)
106  , m_binUtil1(nullptr)
107  , m_binUtil2(nullptr)
108  , m_binUtilArray(nullptr)
109  {
110  // prepare the binUtilities
111  m_binUtil1 = (barr.m_binUtil1) ? barr.m_binUtil1->clone() : 0;
112  m_binUtil2 = (barr.m_binUtil2) ? barr.m_binUtil2->clone() : 0;
113  m_binUtilArray = new std::vector<std::vector<BinUtility*>>;
114  std::vector<std::vector<BinUtility*>>::iterator singleBinIter =
115  barr.m_binUtilArray->begin();
116  for (; singleBinIter != barr.m_binUtilArray->end(); ++singleBinIter) {
117  m_binUtilArray->push_back(
118  std::vector<BinUtility*>((*singleBinIter).size()));
119  for (unsigned int ibin = 0; ibin < m_binUtilArray->back().size(); ibin++)
120  m_binUtilArray->back()[ibin] = (*singleBinIter)[ibin]->clone();
121  }
122 
123  // prepare the binned Array
124  if (m_binUtil1 && m_binUtil2 && m_binUtilArray->size()) {
125  int v1Size = m_binUtil1->bins();
126  int v2Size = m_binUtil2->bins();
127  m_array = std::vector<std::vector<std::vector<SharedObject<T>>>>(v1Size);
128  for (int i = 0; i < v1Size; ++i) {
129  m_array[i] = std::vector<std::vector<SharedObject<T>>>(v2Size);
130  for (int j = 0; j < v2Size; ++j)
131  m_array[i][j] =
132  std::vector<SharedObject<T>>((*m_binUtilArray)[i][j]->bins());
133  }
134 
135  // assign the items
136  for (int ibin1 = 0; ibin1 < v1Size; ++ibin1) {
137  for (int ibin2 = 0; ibin2 < v2Size; ++ibin2) {
138  for (size_t ibin3 = 0;
139  ibin3 < (*m_binUtilArray)[ibin1][ibin2]->bins();
140  ++ibin3) {
141  m_array[ibin1][ibin2][ibin3] = (barr.m_array)[ibin1][ibin2][ibin3];
142  }
143  }
144  }
145  }
146  }

◆ ~BinnedArray1D1D1D()

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

Virtual Destructor.

Definition at line 213 of file BinnedArray1D1D1D.h.

214  {
215  int v1Size = m_binUtil1->bins();
216  int v2Size = m_binUtil2->bins();
217  delete m_binUtil1;
218  delete m_binUtil2;
219 
220  for (int ibin1 = 0; ibin1 < v1Size; ibin1++) {
221  for (int ibin2 = 0; ibin2 < v2Size; ibin2++)
222  delete (*m_binUtilArray)[ibin1][ibin2];
223  }
224  delete m_binUtilArray;
225  }

Member Function Documentation

◆ arrayObjects() [1/2]

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

Return all objects of the Array const T.

Implements Trk::BinnedArray< T >.

Definition at line 281 of file BinnedArray1D1D1D.h.

282  {
284  return BinnedArraySpan<T* const>(&*(m_arrayObjects->begin()), &*(m_arrayObjects->end()));
285  }

◆ arrayObjects() [2/2]

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

Return all objects of the Array const T.

Implements Trk::BinnedArray< T >.

Definition at line 288 of file BinnedArray1D1D1D.h.

289  {
291  return BinnedArraySpan<T const * const>(&*(m_arrayObjects->begin()), &*(m_arrayObjects->end()));
292  }

◆ arrayObjectsNumber()

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

Number of Entries in the Array.

Implements Trk::BinnedArray< T >.

Definition at line 295 of file BinnedArray1D1D1D.h.

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

◆ binUtility()

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

Return the BinUtility - returns the first binUtility in this case.

Implements Trk::BinnedArray< T >.

Definition at line 298 of file BinnedArray1D1D1D.h.

298 { return (m_binUtil1); }

◆ clone()

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

Implicit Constructor.

Implements Trk::BinnedArray< T >.

Definition at line 210 of file BinnedArray1D1D1D.h.

210 { return new BinnedArray1D1D1D(*this); }

◆ createArrayCache()

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

vector of pointers to the class T

Definition at line 301 of file BinnedArray1D1D1D.h.

◆ entryObject()

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

265  {
266  int bin1 = m_binUtil1->entry(gp, 0);
267  int bin2 = m_binUtil2->entry(gp, 0);
268  int bin3 = std::as_const(*m_binUtilArray)[bin1][bin2]->entry(gp, 0);
269 
270  return (m_array[bin1][bin2][bin3]).get();
271  }

◆ nextObject()

template<class T >
T* Trk::BinnedArray1D1D1D< T >::nextObject ( const Amg::Vector3D ,
const Amg::Vector3D ,
bool   
) const
inlinevirtual

Returns the pointer to the templated class object from the BinnedArray dummy for multidimensional arrays

Implements Trk::BinnedArray< T >.

Definition at line 275 of file BinnedArray1D1D1D.h.

276  {
277  return 0;
278  }

◆ object() [1/2]

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

231  {
232  if (!m_binUtil1->inside(lp) || !m_binUtil2->inside(lp))
233  return 0;
234  int bin1 = m_binUtil1->bin(lp);
235  int bin2 = m_binUtil2->bin(lp);
236  if (!std::as_const(*m_binUtilArray)[bin1][bin2]->inside(lp))
237  return 0;
238  int bin3 = std::as_const(*m_binUtilArray)[bin1][bin2]->bin(lp);
239 
240  return (m_array[bin1][bin2][bin3]).get();
241  }

◆ object() [2/2]

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

247  {
248  if (!m_binUtil1->inside(gp) || !m_binUtil2->inside(gp))
249  return 0;
250  int bin1 = m_binUtil1->bin(gp);
251  int bin2 = m_binUtil2->bin(gp);
252  if (!std::as_const(*m_binUtilArray)[bin1][bin2]->inside(gp))
253  return 0;
254  unsigned int bin3 = std::as_const(*m_binUtilArray)[bin1][bin2]->bin(gp);
255 
256  if (bin3 >= std::as_const(*m_binUtilArray)[bin1][bin2]->bins())
257  return 0;
258 
259  return (m_array[bin1][bin2][bin3]).get();
260  }

◆ operator=()

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

Assignment operator.

Definition at line 149 of file BinnedArray1D1D1D.h.

150  {
151  if (this != &barr) {
152 
153  m_arrayObjects.release();
154  // bin utilities
155  size_t v1Size = m_binUtil1->bins();
156  size_t v2Size = m_binUtil2->bins();
157  delete m_binUtil1;
158  delete m_binUtil2;
159 
160  for (size_t ibin1 = 0; ibin1 < v1Size; ibin1++) {
161  for (size_t ibin2 = 0; ibin2 < v2Size; ibin2++)
162  delete (*m_binUtilArray)[ibin1][ibin2];
163  }
164  delete m_binUtilArray;
165  m_binUtilArray = new std::vector<std::vector<BinUtility*>>;
166 
167  // now assign the stuff
168  m_binUtil1 = (barr.m_binUtil1) ? (barr.m_binUtil1)->clone() : 0;
169  m_binUtil2 = (barr.m_binUtil2) ? (barr.m_binUtil2)->clone() : 0;
170 
171  std::vector<std::vector<BinUtility*>>::iterator singleBinIter =
172  barr.m_binUtilArray->begin();
173  for (; singleBinIter != barr.m_binUtilArray->end(); ++singleBinIter) {
174  m_binUtilArray->push_back(
175  std::vector<BinUtility*>((*singleBinIter).size()));
176  for (int ibin = 0; ibin < m_binUtilArray->back().size(); ibin++)
177  m_binUtilArray->back()[ibin] = (*singleBinIter)[ibin]->clone();
178  }
179 
180  // prepare the binned Array
181  if (m_binUtil1 && m_binUtil2 && m_binUtilArray->size()) {
182  size_t v1Size = m_binUtil1->bins();
183  size_t v2Size = m_binUtil2->bins();
184  m_array =
185  std::vector<std::vector<std::vector<SharedObject<T>>>>(v1Size);
186  for (size_t i = 0; i < v1Size; ++i) {
187  m_array[i] = std::vector<std::vector<SharedObject<T>>>(v2Size);
188  for (size_t j = 0; j < v2Size; ++j)
189  m_array[i][j] =
190  std::vector<SharedObject<T>>((*m_binUtilArray)[i][j]->bins());
191  }
192 
193  // assign the items
194  for (size_t ibin1 = 0; ibin1 < v1Size; ++ibin1) {
195  for (size_t ibin2 = 0; ibin2 < v2Size; ++ibin2) {
196  for (size_t ibin3 = 0;
197  ibin3 < (*m_binUtilArray)[ibin1][ibin2]->bins();
198  ++ibin3) {
199  m_array[ibin1][ibin2][ibin3] =
200  (barr.m_array)[ibin1][ibin2][ibin3];
201  }
202  }
203  }
204  }
205  }
206  return *this;
207  }

Member Data Documentation

◆ m_array

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

forced 1D vector of pointers to class T

Definition at line 319 of file BinnedArray1D1D1D.h.

◆ m_arrayObjects

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

Definition at line 321 of file BinnedArray1D1D1D.h.

◆ m_binUtil1

template<class T >
BinUtility* Trk::BinnedArray1D1D1D< T >::m_binUtil1
private

binUtility for retrieving and filling the Array

Definition at line 322 of file BinnedArray1D1D1D.h.

◆ m_binUtil2

template<class T >
BinUtility* Trk::BinnedArray1D1D1D< T >::m_binUtil2
private

binUtility for retrieving and filling the Array

binUtility for retrieving and filling the Array

Definition at line 323 of file BinnedArray1D1D1D.h.

◆ m_binUtilArray

template<class T >
std::vector<std::vector<BinUtility*> >* Trk::BinnedArray1D1D1D< T >::m_binUtilArray
private

Definition at line 325 of file BinnedArray1D1D1D.h.


The documentation for this class was generated from the following file:
xAOD::iterator
JetConstituentVector::iterator iterator
Definition: JetConstituentVector.cxx:68
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::BinnedArray1D1D1D::m_binUtil2
BinUtility * m_binUtil2
binUtility for retrieving and filling the Array
Definition: BinnedArray1D1D1D.h:323
Trk::BinnedArray1D1D1D::BinnedArray1D1D1D
BinnedArray1D1D1D()
Default Constructor - needed for inherited classes.
Definition: BinnedArray1D1D1D.h:43
python.App.bins
bins
Definition: App.py:410
Trk::BinnedArray1D1D1D::createArrayCache
void createArrayCache() const
vector of pointers to the class T
Definition: BinnedArray1D1D1D.h:301
dqt_zlumi_pandas.bin3
bin3
Definition: dqt_zlumi_pandas.py:344
dqt_zlumi_pandas.bin2
bin2
Definition: dqt_zlumi_pandas.py:330
Trk::BinnedArray1D1D1D::m_binUtil1
BinUtility * m_binUtil1
binUtility for retrieving and filling the Array
Definition: BinnedArray1D1D1D.h:322
Trk::BinnedArray1D1D1D::m_array
std::vector< std::vector< std::vector< SharedObject< T > > > > m_array
forced 1D vector of pointers to class T
Definition: BinnedArray1D1D1D.h:319
SharedObject
Trk::BinUtility::bins
size_t bins(size_t ba=0) const
Number of bins.
Definition: BinUtility.h:223
lumiFormat.i
int i
Definition: lumiFormat.py:92
bin2
Definition: KillBinsByStrip.h:34
Trk::BinnedArray1D1D1D::arrayObjects
BinnedArraySpan< T *const > arrayObjects()
Return all objects of the Array const T.
Definition: BinnedArray1D1D1D.h:281
Trk::BinnedArray1D1D1D::m_binUtilArray
std::vector< std::vector< BinUtility * > > * m_binUtilArray
Definition: BinnedArray1D1D1D.h:325
Trk::BinUtility::inside
bool inside(const Amg::Vector3D &position) const
Check if bin is inside from Vector3D.
Definition: BinUtility.h:190
Amg::Vector3D
Eigen::Matrix< double, 3, 1 > Vector3D
Definition: GeoPrimitives.h:47
Trk::inside
@ inside
Definition: PropDirection.h:29
dqt_zlumi_pandas.bin1
bin1
Definition: dqt_zlumi_pandas.py:329
Trk::BinUtility::clone
BinUtility * clone() const
Implizit Constructor.
Definition: BinUtility.h:130
bin3
Definition: BinsOutOfRange.h:33
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::BinnedArray1D1D1D::m_arrayObjects
CxxUtils::CachedUniquePtr< std::vector< T * > > m_arrayObjects
Definition: BinnedArray1D1D1D.h:321