Loading [MathJax]/extensions/tex2jax.js
ATLAS Offline Software
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
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
 
 ~BinnedArray1D1D1D ()=default
 
 BinnedArray1D1D1D (const std::vector< std::pair< SharedObject< T >, Amg::Vector3D >> &tclassvector, const BinUtility &binUtil1, const BinUtility &binUtil2, const std::vector< std::vector< BinUtility >> &binUtilVec)
 Constructor with std::vector and a BinUtility. More...
 
 BinnedArray1D1D1D (const BinnedArray1D1D1D &barr)
 Copy Constructor. More...
 
BinnedArray1D1D1Doperator= (const BinnedArray1D1D1D &barr)
 Assignment operator. More...
 
BinnedArray1D1D1Dclone () const
 Implicit Constructor. 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 {}
 1D cache of non owning pointers to class T More...
 
CxxUtils::CachedUniquePtr< std::vector< T * > > m_arrayObjects {nullptr}
 
BinUtility m_binUtil1 {}
 binUtility for retrieving and filling the Array More...
 
BinUtility m_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 35 of file BinnedArray1D1D1D.h.

Constructor & Destructor Documentation

◆ BinnedArray1D1D1D() [1/3]

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

◆ ~BinnedArray1D1D1D()

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

◆ BinnedArray1D1D1D() [2/3]

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

Constructor with std::vector and a BinUtility.

Definition at line 42 of file BinnedArray1D1D1D.h.

48  : BinnedArray<T>()
49  , m_array{}
50  , m_arrayObjects(nullptr)
51  , m_binUtil1(binUtil1)
52  , m_binUtil2(binUtil2)
53  , m_binUtilArray(binUtilVec)
54  {
55  {
56  int v1Size = binUtil1.bins();
57  int v2Size = binUtil2.bins();
58  m_array = std::vector<std::vector<std::vector<SharedObject<T>>>>(v1Size);
59  for (int i = 0; i < v1Size; ++i) {
60  m_array[i] = std::vector<std::vector<SharedObject<T>>>(v2Size);
61  for (int j = 0; j < v2Size; ++j) {
62  m_array[i][j] =
63  std::vector<SharedObject<T>>((binUtilVec)[i][j].bins());
64  }
65  }
66  }
67  // fill the Volume vector into the array
68  int vecsize(tclassvector.size());
69  for (int ivec = 0; ivec < vecsize; ++ivec) {
70  Amg::Vector3D currentGlobal((tclassvector[ivec]).second);
71  if (binUtil1.inside(currentGlobal) && binUtil2.inside(currentGlobal)) {
72  int bin1 = binUtil1.bin(currentGlobal);
73  int bin2 = binUtil2.bin(currentGlobal);
74  assert((*binUtilVec)[bin1][bin2]);
75  int bin3 = (binUtilVec)[bin1][bin2].bin(currentGlobal);
76  std::vector<std::vector<SharedObject<T>>>& currArr = m_array[bin1];
77  std::vector<SharedObject<T>>& curVec = currArr[bin2];
78  curVec[bin3] = ((tclassvector)[ivec]).first;
79  } else
80  throw GaudiException(
81  "BinnedArray1D1D1D", "Object outside bounds", StatusCode::FAILURE);
82  }
83  }

◆ BinnedArray1D1D1D() [3/3]

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

Copy Constructor.

Definition at line 86 of file BinnedArray1D1D1D.h.

87  : BinnedArray<T>()
88  , m_array{}
89  , m_arrayObjects(nullptr)
90  , m_binUtil1(barr.m_binUtil1)
91  , m_binUtil2(barr.m_binUtil2)
92  , m_binUtilArray(barr.m_binUtilArray)
93  {
94  // prepare the binned Array
95  if (m_binUtilArray.size()) {
96  int v1Size = m_binUtil1.bins();
97  int v2Size = m_binUtil2.bins();
98  m_array = std::vector<std::vector<std::vector<SharedObject<T>>>>(v1Size);
99  for (int i = 0; i < v1Size; ++i) {
100  m_array[i] = std::vector<std::vector<SharedObject<T>>>(v2Size);
101  for (int j = 0; j < v2Size; ++j){
102  m_array[i][j] =
103  std::vector<SharedObject<T>>((m_binUtilArray)[i][j].bins());
104  }
105  }
106  // assign the items
107  for (int ibin1 = 0; ibin1 < v1Size; ++ibin1) {
108  for (int ibin2 = 0; ibin2 < v2Size; ++ibin2) {
109  for (size_t ibin3 = 0; ibin3 < (m_binUtilArray)[ibin1][ibin2].bins(); ++ibin3) {
110  m_array[ibin1][ibin2][ibin3] = (barr.m_array)[ibin1][ibin2][ibin3];
111  }
112  }
113  }
114  }
115  }

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 209 of file BinnedArray1D1D1D.h.

210  {
212  return BinnedArraySpan<T* const>(&*(m_arrayObjects->begin()), &*(m_arrayObjects->end()));
213  }

◆ 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 216 of file BinnedArray1D1D1D.h.

217  {
219  return BinnedArraySpan<T const * const>(&*(m_arrayObjects->begin()), &*(m_arrayObjects->end()));
220  }

◆ 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 223 of file BinnedArray1D1D1D.h.

223 { 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 226 of file BinnedArray1D1D1D.h.

226 { return &m_binUtil1; }

◆ clone()

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

Implicit Constructor.

Implements Trk::BinnedArray< T >.

Definition at line 151 of file BinnedArray1D1D1D.h.

151 { 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 229 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 193 of file BinnedArray1D1D1D.h.

194  {
195  int bin1 = m_binUtil1.entry(gp, 0);
196  int bin2 = m_binUtil2.entry(gp, 0);
197  int bin3 = std::as_const(m_binUtilArray)[bin1][bin2].entry(gp, 0);
198  return (m_array[bin1][bin2][bin3]).get();
199  }

◆ 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 203 of file BinnedArray1D1D1D.h.

204  {
205  return 0;
206  }

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

157  {
158  if (!m_binUtil1.inside(lp) || !m_binUtil2.inside(lp))
159  return 0;
160  int bin1 = m_binUtil1.bin(lp);
161  int bin2 = m_binUtil2.bin(lp);
162  if (!std::as_const(m_binUtilArray)[bin1][bin2].inside(lp)){
163  return 0;
164  }
165  int bin3 = std::as_const(m_binUtilArray)[bin1][bin2].bin(lp);
166 
167  return (m_array[bin1][bin2][bin3]).get();
168  }

◆ 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 173 of file BinnedArray1D1D1D.h.

174  {
175  if (!m_binUtil1.inside(gp) || !m_binUtil2.inside(gp))
176  return 0;
177  int bin1 = m_binUtil1.bin(gp);
178  int bin2 = m_binUtil2.bin(gp);
179  if (!std::as_const(m_binUtilArray)[bin1][bin2].inside(gp)){
180  return 0;
181  }
182  unsigned int bin3 = std::as_const(m_binUtilArray)[bin1][bin2].bin(gp);
183 
184  if (bin3 >= std::as_const(m_binUtilArray)[bin1][bin2].bins()){
185  return 0;
186  }
187 
188  return (m_array[bin1][bin2][bin3]).get();
189  }

◆ operator=()

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

Assignment operator.

Definition at line 118 of file BinnedArray1D1D1D.h.

119  {
120  if (this != &barr) {
121  // bin utilities
122  m_binUtil1 = (barr.m_binUtil1);
123  m_binUtil2 = (barr.m_binUtil2);
124  m_binUtilArray = (barr.m_binUtilArray);
125  size_t v1Size = m_binUtil1.bins();
126  size_t v2Size = m_binUtil2.bins();
127  //cached ptr release
128  m_arrayObjects.release();
129  // prepare the binned Array
130  if (m_binUtilArray.size()) {
131  m_array = std::vector<std::vector<std::vector<SharedObject<T>>>>(v1Size);
132  for (size_t i = 0; i < v1Size; ++i) {
133  m_array[i] = std::vector<std::vector<SharedObject<T>>>(v2Size);
134  for (size_t j = 0; j < v2Size; ++j){
135  m_array[i][j] = std::vector<SharedObject<T>>((m_binUtilArray)[i][j].bins());
136  }
137  }
138  // assign the items
139  for (size_t ibin1 = 0; ibin1 < v1Size; ++ibin1) {
140  for (size_t ibin2 = 0; ibin2 < v2Size; ++ibin2) {
141  for (size_t ibin3 = 0; ibin3 < m_binUtilArray[ibin1][ibin2].bins(); ++ibin3) {
142  m_array[ibin1][ibin2][ibin3] = barr.m_array[ibin1][ibin2][ibin3];
143  }
144  }
145  }
146  }
147  }
148  return *this;
149  }

Member Data Documentation

◆ m_array

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

1D cache of non owning pointers to class T

Definition at line 244 of file BinnedArray1D1D1D.h.

◆ m_arrayObjects

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

Definition at line 246 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 247 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 248 of file BinnedArray1D1D1D.h.

◆ m_binUtilArray

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

Definition at line 250 of file BinnedArray1D1D1D.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:136
Trk::BinnedArray1D1D1D::m_binUtil1
BinUtility m_binUtil1
binUtility for retrieving and filling the Array
Definition: BinnedArray1D1D1D.h:247
python.SystemOfUnits.second
int second
Definition: SystemOfUnits.py:120
Trk::BinnedArray1D1D1D::createArrayCache
void createArrayCache() const
vector of pointers to the class T
Definition: BinnedArray1D1D1D.h:229
dqt_zlumi_pandas.bin3
bin3
Definition: dqt_zlumi_pandas.py:351
Trk::BinnedArray1D1D1D::m_binUtilArray
std::vector< std::vector< BinUtility > > m_binUtilArray
Definition: BinnedArray1D1D1D.h:250
dqt_zlumi_pandas.bin2
bin2
Definition: dqt_zlumi_pandas.py:337
Trk::BinnedArray1D1D1D::m_array
std::vector< std::vector< std::vector< SharedObject< T > > > > m_array
1D cache of non owning pointers to class T
Definition: BinnedArray1D1D1D.h:244
Trk::BinUtility::bins
size_t bins(size_t ba=0) const
Number of bins.
Definition: BinUtility.h:221
Trk::BinnedArray1D1D1D::BinnedArray1D1D1D
BinnedArray1D1D1D()=default
lumiFormat.i
int i
Definition: lumiFormat.py:85
plotting.yearwise_luminosity_vs_mu.bins
bins
Definition: yearwise_luminosity_vs_mu.py:30
bin2
Definition: KillBinsByStrip.h:34
Trk::BinnedArray1D1D1D::arrayObjects
BinnedArraySpan< T *const > arrayObjects()
Return all objects of the Array const T.
Definition: BinnedArray1D1D1D.h:209
Trk::BinUtility::inside
bool inside(const Amg::Vector3D &position) const
Check if bin is inside from Vector3D.
Definition: BinUtility.h:186
plotBeamSpotVxVal.bin
int bin
Definition: plotBeamSpotVxVal.py:83
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:336
bin3
Definition: BinsOutOfRange.h:33
Trk::BinnedArray1D1D1D::m_binUtil2
BinUtility m_binUtil2
binUtility for retrieving and filling the Array
Definition: BinnedArray1D1D1D.h:248
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:126
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:246