ATLAS Offline Software
BinnedArrayArray.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3 */
4 
6 // BinnedArrayArray.h, (c) ATLAS Detector software
8 
9 #ifndef TRKDETDESCRUTILS_BINNEDARRAYARRAY_H
10 #define TRKDETDESCRUTILS_BINNEDARRAYARRAY_H
11 
15 // GaudiKernel
16 #include "GaudiKernel/GaudiException.h"
17 // Eigen
19 // STL
20 #include <vector>
21 
22 class MsgStream;
23 
24 namespace Trk {
25 
34 template<class T>
35 class BinnedArrayArray final : public BinnedArray<T>
36 {
37 
38 public:
41  const std::vector<std::pair<BinnedArray<T>*, Amg::Vector3D>>& tbas,
42  BinUtility* bUtility)
43  : m_binUtility(bUtility)
44  , m_binnedArrays(bUtility->bins(0), nullptr)
45  , m_arrayObjects()
46  {
47  // the array objects
48  m_arrayObjects.reserve(tbas.size() * bUtility->bins(0));
49  // looping over the contained binned arraysa
50  for (auto& barray : tbas) {
51  // binned array ordering
52  m_binnedArrays[bUtility->bin(barray.second, 0)] = barray.first;
53  // get the array objects
54  BinnedArraySpan<T * const > aObjects = barray.first->arrayObjects();
55  for (auto& o : aObjects)
56  m_arrayObjects.push_back(o);
57  }
58  }
59 
64  {
66  }
67 
70  {
71  delete m_binUtility;
73  }
74 
77  {
78  if (&baa != this) {
79  delete m_binUtility;
81 
84 
86  }
87  return *this;
88  }
89 
91  virtual BinnedArrayArray* clone() const override
92  {
93  return new BinnedArrayArray(*this);
94  }
95 
98  virtual T* object(const Amg::Vector2D& lp) const override
99  {
100  if (m_binUtility->inside(lp)) {
102  if (ba)
103  return ba->object(lp);
104  }
105  return nullptr;
106  }
107 
110  virtual T* object(const Amg::Vector3D& gp) const override
111  {
112  if (m_binUtility->inside(gp)) {
114  if (ba)
115  return ba->object(gp);
116  }
117  return nullptr;
118  }
119 
122  virtual T* entryObject(const Amg::Vector3D& gp) const override
123  {
124  return object(gp);
125  }
126 
129  virtual T* nextObject(const Amg::Vector3D& gp,
130  const Amg::Vector3D&,
131  bool) const override
132  {
133  return object(gp);
134  }
135 
137  virtual BinnedArraySpan<T* const > arrayObjects() override final
138  {
139  return BinnedArraySpan<T* const >(&*m_arrayObjects.begin(), &*m_arrayObjects.end());
140  }
141 
144  {
146  }
147 
149  virtual unsigned int arrayObjectsNumber() const override final
150  {
151  return m_arrayObjects.size();
152  };
153 
155  virtual const BinUtility* binUtility() const override { return m_binUtility; }
156 
157 private:
161  {
162  for (auto ba : m_binnedArrays) {
163  delete ba;
164  }
165  m_binnedArrays.clear();
166  }
167 
172  void copyBinnedArrays(const std::vector<BinnedArray<T>*>& binned_arrays)
173  {
174  m_binnedArrays.reserve(binned_arrays.size());
175 
176  for (const auto& a_binned_array : binned_arrays) {
177  m_binnedArrays.push_back(a_binned_array->clone());
178  }
179  }
180 
182  std::vector<BinnedArray<T>*> m_binnedArrays;
183  std::vector<T*> m_arrayObjects;
184 };
185 } // end of namespace Trk
186 
187 #endif // TRKDETDESCRUTILS_BINNEDARRAYARRAY_H
Trk::BinnedArrayArray::arrayObjects
virtual BinnedArraySpan< T const *const > arrayObjects() const override final
Return all objects of the Array const T.
Definition: BinnedArrayArray.h:143
Trk::BinnedArrayArray::clone
virtual BinnedArrayArray * clone() const override
Implicit constructor.
Definition: BinnedArrayArray.h:91
Trk::BinnedArrayArray::BinnedArrayArray
BinnedArrayArray(const BinnedArrayArray &baa)
Copy Constructor.
Definition: BinnedArrayArray.h:61
Amg::Vector2D
Eigen::Matrix< double, 2, 1 > Vector2D
Definition: GeoPrimitives.h:48
BinnedArray.h
Trk::BinnedArrayArray::m_binUtility
BinUtility * m_binUtility
Definition: BinnedArrayArray.h:181
BinUtility.h
Trk::BinnedArray::object
virtual T * object(const Amg::Vector2D &lp) const =0
Returns the pointer to the templated class object from the BinnedArray, it returns 0 if not defined,...
Trk::BinnedArrayArray::deleteBinnedArrays
void deleteBinnedArrays()
cleanup the array of binned arrays.
Definition: BinnedArrayArray.h:160
Trk::BinnedArrayArray::BinnedArrayArray
BinnedArrayArray(const std::vector< std::pair< BinnedArray< T > *, Amg::Vector3D >> &tbas, BinUtility *bUtility)
Default Constructor
Definition: BinnedArrayArray.h:40
const
bool const RAWDATA *ch2 const
Definition: LArRodBlockPhysicsV0.cxx:560
Trk::BinnedArrayArray::operator=
BinnedArrayArray & operator=(const BinnedArrayArray &baa)
assignment operator matching the copy constructor
Definition: BinnedArrayArray.h:76
Trk::BinUtility::bins
size_t bins(size_t ba=0) const
Number of bins.
Definition: BinUtility.h:223
Trk::BinnedArrayArray::nextObject
virtual T * nextObject(const Amg::Vector3D &gp, const Amg::Vector3D &, bool) const override
Returns the pointer to the templated class object from the BinnedArrayArray, takes 3D position & dire...
Definition: BinnedArrayArray.h:129
Trk::BinnedArrayArray::arrayObjectsNumber
virtual unsigned int arrayObjectsNumber() const override final
Number of Entries in the Array.
Definition: BinnedArrayArray.h:149
Trk::BinnedArrayArray::entryObject
virtual T * entryObject(const Amg::Vector3D &gp) const override
Returns the pointer to the templated class object from the BinnedArrayArray - entry point.
Definition: BinnedArrayArray.h:122
GeoPrimitives.h
Trk::BinnedArrayArray::binUtility
virtual const BinUtility * binUtility() const override
Return the BinUtility.
Definition: BinnedArrayArray.h:155
plotting.yearwise_luminosity_vs_mu.bins
bins
Definition: yearwise_luminosity_vs_mu.py:30
SharedObject.h
Trk::BinUtility
Definition: BinUtility.h:39
Trk
Ensure that the ATLAS eigen extensions are properly loaded.
Definition: FakeTrackBuilder.h:9
Trk::BinUtility::inside
bool inside(const Amg::Vector3D &position) const
Check if bin is inside from Vector3D.
Definition: BinUtility.h:190
Trk::BinnedArrayArray::arrayObjects
virtual BinnedArraySpan< T *const > arrayObjects() override final
Return all objects of the Array non-const T.
Definition: BinnedArrayArray.h:137
Trk::BinnedArrayArray::object
virtual T * object(const Amg::Vector3D &gp) const override
Returns the pointer to the templated class object from the BinnedArrayArray it returns 0 if not defin...
Definition: BinnedArrayArray.h:110
Amg::Vector3D
Eigen::Matrix< double, 3, 1 > Vector3D
Definition: GeoPrimitives.h:47
Trk::BinnedArrayArray::copyBinnedArrays
void copyBinnedArrays(const std::vector< BinnedArray< T > * > &binned_arrays)
Build up binned arrays array from cloned binned arrays.
Definition: BinnedArrayArray.h:172
Trk::BinnedArrayArray
Definition: BinnedArrayArray.h:36
Trk::BinnedArrayArray::object
virtual T * object(const Amg::Vector2D &lp) const override
Returns the pointer to the templated class object from the BinnedArrayArray, it returns 0 if not defi...
Definition: BinnedArrayArray.h:98
Trk::BinUtility::clone
BinUtility * clone() const
Implizit Constructor.
Definition: BinUtility.h:130
Trk::BinnedArrayArray::m_binnedArrays
std::vector< BinnedArray< T > * > m_binnedArrays
Definition: BinnedArrayArray.h:182
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::BinnedArray
Definition: BinnedArray.h:38
Trk::BinnedArrayArray::~BinnedArrayArray
virtual ~BinnedArrayArray()
Virtual Destructor.
Definition: BinnedArrayArray.h:69
Trk::BinnedArraySpan
std::span< T > BinnedArraySpan
Definition: BinnedArray.h:34
Trk::BinnedArrayArray::m_arrayObjects
std::vector< T * > m_arrayObjects
Definition: BinnedArrayArray.h:183