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

#include <BinnedArray1D1D.h>

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

Public Member Functions

 BinnedArray1D1D ()
 Default Constructor - needed for inherited classes. More...
 
 BinnedArray1D1D (const std::vector< std::pair< SharedObject< T >, Amg::Vector3D >> &tclassvector, BinUtility *steeringBinGen1D, std::vector< BinUtility * > *singleBinGen)
 Constructor with std::vector and a BinUtility. More...
 
 BinnedArray1D1D (const BinnedArray1D1D &barr)
 Copy Constructor - copies only pointers! More...
 
BinnedArray1D1Doperator= (const BinnedArray1D1D &barr)
 Assignment operator. More...
 
BinnedArray1D1Dclone () const
 Implicit Constructor. More...
 
virtual ~BinnedArray1D1D ()
 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. 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 - returns the steering 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< 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...
 
BinUtilitym_steeringBinUtility
 
std::vector< BinUtility * > * m_singleBinUtilities
 single bin utilities More...
 

Detailed Description

template<class T>
class Trk::BinnedArray1D1D< T >

2D dimensional binned array, where the binning grid is not symmetric. One steering bin utility finds the associated array of the other.

Author
Andre.nosp@m.as.S.nosp@m.alzbu.nosp@m.rger.nosp@m.@cern.nosp@m..ch
Christos Anastopoulos (Athena MT modifications)

Definition at line 35 of file BinnedArray1D1D.h.

Constructor & Destructor Documentation

◆ BinnedArray1D1D() [1/3]

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

Default Constructor - needed for inherited classes.

Definition at line 40 of file BinnedArray1D1D.h.

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

◆ BinnedArray1D1D() [2/3]

template<class T >
Trk::BinnedArray1D1D< T >::BinnedArray1D1D ( const std::vector< std::pair< SharedObject< T >, Amg::Vector3D >> &  tclassvector,
BinUtility steeringBinGen1D,
std::vector< BinUtility * > *  singleBinGen 
)
inline

Constructor with std::vector and a BinUtility.

Definition at line 49 of file BinnedArray1D1D.h.

53  : BinnedArray<T>()
54  , m_array{}
55  , m_arrayObjects(nullptr)
56  , m_steeringBinUtility(steeringBinGen1D)
57  , m_singleBinUtilities(singleBinGen)
58  {
59 
60  // prepare the binned Array
61  if (steeringBinGen1D) {
62  m_array =
63  std::vector<std::vector<SharedObject<T>>>(steeringBinGen1D->bins());
64  for (size_t i = 0; i < steeringBinGen1D->bins(); ++i) {
65  size_t sizeOfSubBin = ((*m_singleBinUtilities)[i])->bins();
66  m_array[i] = std::vector<SharedObject<T>>(sizeOfSubBin);
67  }
68 
69  // fill the Volume vector into the array
70  int vecsize(tclassvector.size());
71  for (int ivec = 0; ivec < vecsize; ++ivec) {
72  const Amg::Vector3D currentGlobal((tclassvector[ivec]).second);
73  if (steeringBinGen1D->inside(currentGlobal)) {
74  int steeringBin = steeringBinGen1D->bin(currentGlobal, 0);
75  int singleBin =
76  ((*m_singleBinUtilities)[steeringBin])->bin(currentGlobal, 0);
77  std::vector<SharedObject<T>>& curVec = m_array[steeringBin];
78  curVec[singleBin] = ((tclassvector)[ivec]).first;
79  } else
80  throw GaudiException(
81  "BinnedArray1D1D", "Object outside bounds", StatusCode::FAILURE);
82  }
83  }
84  }

◆ BinnedArray1D1D() [3/3]

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

Copy Constructor - copies only pointers!

Definition at line 87 of file BinnedArray1D1D.h.

88  : BinnedArray<T>()
89  , m_array{}
90  , m_arrayObjects(nullptr)
91  , m_steeringBinUtility(nullptr)
92  , m_singleBinUtilities(nullptr)
93  {
94  // prepare the binUtilities
95  m_steeringBinUtility = (barr.m_steeringBinUtility)
96  ? barr.m_steeringBinUtility->clone()
97  : nullptr;
98  m_singleBinUtilities = new std::vector<BinUtility*>;
100  barr.m_singleBinUtilities->begin();
101  for (; singleBinIter != barr.m_singleBinUtilities->end(); ++singleBinIter) {
102  m_singleBinUtilities->push_back((*singleBinIter)->clone());
103  }
104 
105  // prepare the binned Array
106  if (m_steeringBinUtility && !m_singleBinUtilities->empty()) {
107  // prepare the array
108  m_array = std::vector<std::vector<SharedObject<T>>>(
110  for (size_t i = 0; i < m_steeringBinUtility->bins(0); ++i) {
111  size_t sizeOfSubBin = ((*m_singleBinUtilities)[i])->bins(0);
112  m_array[i] = std::vector<SharedObject<T>>(sizeOfSubBin, nullptr);
113  }
114 
115  // assign the items
116  for (size_t isteer = 0; isteer < m_steeringBinUtility->bins(0);
117  ++isteer) {
118  for (size_t isingle = 0;
119  isingle < (*m_singleBinUtilities)[isteer]->bins(0);
120  ++isteer) {
121  m_array[isteer][isingle] = (barr.m_array)[isteer][isingle];
122  }
123  }
124  }
125  }

◆ ~BinnedArray1D1D()

template<class T >
virtual Trk::BinnedArray1D1D< T >::~BinnedArray1D1D ( )
inlinevirtual

Virtual Destructor.

Definition at line 178 of file BinnedArray1D1D.h.

179  {
180  delete m_steeringBinUtility;
181  if (m_singleBinUtilities) {
183  m_singleBinUtilities->begin();
184  for (; binIter != m_singleBinUtilities->end(); ++binIter) {
185  delete *binIter;
186  }
187  }
188  delete m_singleBinUtilities;
189  }

Member Function Documentation

◆ arrayObjects() [1/2]

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

Return all objects of the Array non-const T.

Implements Trk::BinnedArray< T >.

Definition at line 227 of file BinnedArray1D1D.h.

228  {
230  return Trk::BinnedArraySpan<T* const>(&*(m_arrayObjects->begin()), &*(m_arrayObjects->end()));
231  }

◆ arrayObjects() [2/2]

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

Return all objects of the Array const T.

Implements Trk::BinnedArray< T >.

Definition at line 234 of file BinnedArray1D1D.h.

235  {
237  return BinnedArraySpan<const T* const>(&*(m_arrayObjects->begin()), &*(m_arrayObjects->end()));
238  }

◆ arrayObjectsNumber()

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

Number of Entries in the Array.

Implements Trk::BinnedArray< T >.

Definition at line 241 of file BinnedArray1D1D.h.

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

◆ binUtility()

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

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

Implements Trk::BinnedArray< T >.

Definition at line 244 of file BinnedArray1D1D.h.

244 { return (m_steeringBinUtility); }

◆ clone()

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

Implicit Constructor.

Implements Trk::BinnedArray< T >.

Definition at line 175 of file BinnedArray1D1D.h.

175 { return new BinnedArray1D1D(*this); }

◆ createArrayCache()

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

vector of pointers to the class T

Definition at line 247 of file BinnedArray1D1D.h.

◆ entryObject()

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

214  {
215  int steerBin = m_steeringBinUtility->entry(gp, 0);
216  int singleBin = std::as_const(*m_singleBinUtilities)[steerBin]->entry(gp, 0);
217  return (m_array[steerBin][singleBin]).get();
218  }

◆ nextObject()

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

Returns the pointer to the templated class object from the BinnedArray.

Implements Trk::BinnedArray< T >.

Definition at line 221 of file BinnedArray1D1D.h.

222  {
223  return nullptr;
224  }

◆ object() [1/2]

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

195  {
196  int steerBin = m_steeringBinUtility->bin(lp, 0);
197  int singleBin = std::as_const(*m_singleBinUtilities)[steerBin]->bin(lp, 0);
198  return (m_array[steerBin][singleBin]).get();
199  }

◆ object() [2/2]

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

205  {
206  int steerBin = m_steeringBinUtility->bin(gp, 0);
207  int singleBin = std::as_const(*m_singleBinUtilities)[steerBin]->bin(gp, 0);
208  return (m_array[steerBin][singleBin]).get();
209  }

◆ operator=()

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

Assignment operator.

Definition at line 128 of file BinnedArray1D1D.h.

129  {
130  if (this != &barr) {
131 
132  m_arrayObjects.release();
133  delete m_steeringBinUtility;
134 
135  std::vector<BinUtility*>::iterator singleBinIter =
136  m_singleBinUtilities->begin();
137  for (; singleBinIter != m_singleBinUtilities->end(); ++singleBinIter) {
138  delete *singleBinIter;
139  }
140  delete m_singleBinUtilities;
141  m_singleBinUtilities = new std::vector<BinUtility*>;
142 
143  // now assign the stuff
145  (barr.m_steeringBinUtility) ? (barr.m_steeringBinUtility)->clone() : 0;
146 
147  singleBinIter = barr.m_singleBinUtilties->begin();
148  for (; singleBinIter != barr.m_singleBinUtilities->end(); ++singleBinIter)
149  m_singleBinUtilities->push_back((*singleBinIter)->clone());
150 
151  // prepare the binned Array
153  // prepare the array
154  m_array = std::vector<std::vector<SharedObject<T>>>(
156  for (int i = 0; i < m_steeringBinUtility->bins(0); ++i) {
157  unsigned int sizeOfSubBin = ((*m_singleBinUtilities)[i])->bins(0);
158  m_array[i] = std::vector<SharedObject<T>>(sizeOfSubBin);
159  }
160 
161  // assign the items
162  for (int isteer = 0; isteer < m_steeringBinUtility->bins(0); ++isteer) {
163  for (int isingle = 0;
164  isingle < (*m_singleBinUtilities)[isteer]->bins(0);
165  ++isteer) {
166  m_array[isteer][isingle] = (barr.m_array)[isteer][isingle];
167  }
168  }
169  }
170  }
171  return *this;
172  }

Member Data Documentation

◆ m_array

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

forced 1D vector of pointers to class T

Definition at line 263 of file BinnedArray1D1D.h.

◆ m_arrayObjects

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

binUtility for retrieving and filling the Array

Definition at line 265 of file BinnedArray1D1D.h.

◆ m_singleBinUtilities

template<class T >
std::vector<BinUtility*>* Trk::BinnedArray1D1D< T >::m_singleBinUtilities
private

single bin utilities

Definition at line 268 of file BinnedArray1D1D.h.

◆ m_steeringBinUtility

template<class T >
BinUtility* Trk::BinnedArray1D1D< T >::m_steeringBinUtility
private

Definition at line 267 of file BinnedArray1D1D.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::BinnedArray1D1D::m_steeringBinUtility
BinUtility * m_steeringBinUtility
Definition: BinnedArray1D1D.h:267
Trk::BinnedArray1D1D::m_arrayObjects
CxxUtils::CachedUniquePtr< std::vector< T * > > m_arrayObjects
binUtility for retrieving and filling the Array
Definition: BinnedArray1D1D.h:265
Trk::BinnedArray1D1D::m_singleBinUtilities
std::vector< BinUtility * > * m_singleBinUtilities
single bin utilities
Definition: BinnedArray1D1D.h:268
Trk::BinnedArray1D1D::m_array
std::vector< std::vector< SharedObject< T > > > m_array
forced 1D vector of pointers to class T
Definition: BinnedArray1D1D.h:263
Trk::BinUtility::bins
size_t bins(size_t ba=0) const
Number of bins.
Definition: BinUtility.h:223
Trk::BinnedArray1D1D::arrayObjects
BinnedArraySpan< T *const > arrayObjects()
Return all objects of the Array non-const T.
Definition: BinnedArray1D1D.h:227
lumiFormat.i
int i
Definition: lumiFormat.py:85
Trk::BinnedArray1D1D::createArrayCache
void createArrayCache() const
vector of pointers to the class T
Definition: BinnedArray1D1D.h:247
Trk::BinnedArray1D1D::BinnedArray1D1D
BinnedArray1D1D()
Default Constructor - needed for inherited classes.
Definition: BinnedArray1D1D.h:40
plotting.yearwise_luminosity_vs_mu.bins
bins
Definition: yearwise_luminosity_vs_mu.py:30
plotBeamSpotVxVal.bin
int bin
Definition: plotBeamSpotVxVal.py:83
Amg::Vector3D
Eigen::Matrix< double, 3, 1 > Vector3D
Definition: GeoPrimitives.h:47
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
CxxUtils::ivec
vec_fb< typename boost::int_t< sizeof(T) *8 >::exact, N > ivec
Definition: vec_fb.h:53
Trk::BinnedArraySpan
std::span< T > BinnedArraySpan
Definition: BinnedArray.h:34