ATLAS Offline Software
Loading...
Searching...
No Matches
CompactBinnedArray1D.h
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3*/
4
6// CompactBinnedArray1D.h, (c) ATLAS Detector software
8
9#ifndef TRKDETDESCRUTILS_COMPACTBINNEDARRAY1D_H
10#define TRKDETDESCRUTILS_COMPACTBINNEDARRAY1D_H
11
14
15// STL
16#include <vector>
17
18class MsgStream;
19
20namespace Trk {
21
30
31template<class T>
33{
34public:
35
36 //Rule of 0 for default ctors
37
40 CompactBinnedArray1D(const std::vector<T*>& tclassvector,
41 const std::vector<size_t>& indexvector,
42 const BinUtility& bingen)
43 : CompactBinnedArray<T>(),
44 m_array(indexvector),
45 m_arrayObjects(tclassvector),
46 m_binUtility(bingen) {}
47
48 CompactBinnedArray1D(const std::vector<T*>& tclassvector,
49 std::vector<size_t>&& indexvector,
50 BinUtility&& bingen)
51 : CompactBinnedArray<T>(),
52 m_array(std::move(indexvector)),
53 m_arrayObjects(tclassvector),
54 m_binUtility(std::move(bingen)) {}
55
61
62 CompactBinnedArray1D* clone(const std::vector<T*>& ptrs) const
63 {
64 assert(ptrs.size() == m_arrayObjects.size());
65 return new CompactBinnedArray1D(ptrs, m_array, m_binUtility);
66 }
67
71 T* object(const Amg::Vector2D& lp) const
72 {
73 if (m_binUtility.inside(lp)){
74 return m_arrayObjects[m_array[m_binUtility.bin(lp, 0)]];
75 }
76 return nullptr;
77 }
78
82 T* object(const Amg::Vector3D& gp) const
83 {
84 return m_arrayObjects[m_array[m_binUtility.bin(gp, 0)]];
85 }
86
89 T* entryObject(const Amg::Vector3D& gp) const
90 {
91 return (m_arrayObjects[m_array[m_binUtility.entry(gp, 0)]]);
92 }
93
97 const Amg::Vector3D& mom,
98 bool associatedResult = true) const
99 {
100 // the bins
101 size_t bin = associatedResult ? m_binUtility.bin(gp, 0)
102 : m_binUtility.next(gp, mom, 0);
103 return m_arrayObjects[m_array[bin]];
104 }
105
107 std::span<T* const> arrayObjects()
108 {
109 return std::span<T* const>(m_arrayObjects.begin(),m_arrayObjects.end());
110 }
111
113 std::span<T const * const> arrayObjects() const
114 {
115 return std::span<T const * const>(m_arrayObjects.begin(),m_arrayObjects.end());
116 }
117
119 unsigned int arrayObjectsNumber() const { return m_arrayObjects.size(); }
120
122 const BinUtility* binUtility() const { return &m_binUtility; }
123
126 {
127 return &m_binUtility;
128 }
129
131 size_t layerBin(const Amg::Vector3D& pos) const
132 {
133 return m_binUtility.bin(pos);
134 }
135
136private:
137 std::vector<size_t> m_array{};
138 std::vector<T*> m_arrayObjects{};
140};
141
142} // end of namespace Trk
143
144#endif // TRKDETDESCRUTILS_COMPACTBINNEDARRAY1D_H
A generic symmetric BinUtility, for fully symmetric binning in terms of binning grid and binning type...
Definition BinUtility.h:39
T * object(const Amg::Vector2D &lp) const
Returns the pointer to the templated class object from the BinnedArray, it returns nullptr if not def...
CompactBinnedArray1D * clone() const
Implicit Constructor.
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.
size_t layerBin(const Amg::Vector3D &pos) const
Return the layer bin.
CompactBinnedArray1D(const std::vector< T * > &tclassvector, const std::vector< size_t > &indexvector, const BinUtility &bingen)
Constructor with arguents.
T * object(const Amg::Vector3D &gp) const
Returns the pointer to the templated class object from the BinnedArray it returns nullptr if not defi...
BinUtility m_binUtility
binUtility
std::vector< T * > m_arrayObjects
not owning pointers to objects
const BinUtility * layerBinUtility(const Amg::Vector3D &) const
Return the BinUtility.
std::span< T const *const > arrayObjects() const
Return all objects of the Array const T.
std::span< T *const > arrayObjects()
Return all objects of the Array non const T.
unsigned int arrayObjectsNumber() const
Number of Entries in the Array.
T * entryObject(const Amg::Vector3D &gp) const
Returns the pointer to the templated class object from the BinnedArray - entry point.
CompactBinnedArray1D * clone(const std::vector< T * > &ptrs) const
const BinUtility * binUtility() const
Return the BinUtility.
CompactBinnedArray1D(const std::vector< T * > &tclassvector, std::vector< size_t > &&indexvector, BinUtility &&bingen)
std::vector< size_t > m_array
vector of indices to objects
defines common utilities needed for implementation of binned material
Eigen::Matrix< double, 2, 1 > Vector2D
Eigen::Matrix< double, 3, 1 > Vector3D
Ensure that the ATLAS eigen extensions are properly loaded.
STL namespace.