ATLAS Offline Software
Classes | Public Types | Public Member Functions | Static Public Member Functions | Static Public Attributes | Protected Attributes | List of all members
InDetDD::PixelDiodeTree Class Reference

Tree structure to find the position, index or pitch of a pixel on a semi-regular grid The grid is considered regular if sub grids resulting from consecutive splits in local-x and local-y direction have identical pitch. More...

#include <PixelDiodeTree.h>

Collaboration diagram for InDetDD::PixelDiodeTree:

Classes

struct  DiodeParam
 Parameters of a diode. More...
 
struct  DiodeProxy
 Helper class to access parameters of a diode. More...
 
struct  DiodeProxyWithPosition
 A diode proxy which caches the position of a diode. More...
 

Public Types

using Vector2D = Amg::Vector2D
 
using FloatType = Amg::Vector2D::Scalar
 
using CellIndexType = int
 
using IndexType = int
 
using AttributeType = unsigned int
 

Public Member Functions

 PixelDiodeTree (const Vector2D &total_width)
 
unsigned int addDiode (const Vector2D &width, AttributeType attribute)
 
void setDiodeForSubMatrix (unsigned int sub_matrix_idx, unsigned int split_i, unsigned int diode_idx)
 
unsigned int split (const std::array< CellIndexType, 2 > &idx_split, const Vector2D &pos_split, AttributeType an_attribute, unsigned int parent_idx=std::numeric_limits< unsigned int >::max(), unsigned int split_i=0)
 
template<typename T >
std::tuple< IndexType, IndexType, IndexTypefindFromT (const T &val, const std::vector< T > &split) const
 helper template to find the final node in a quad tree. More...
 
Vector2D computePosition (PixelDiodeTree::IndexType sub_matrix_idx, PixelDiodeTree::IndexType diode_idx, const std::array< CellIndexType, 2 > &idx) const
 Compute the position of a certain diode in a certain sub-matrix. More...
 
std::array< CellIndexType, 2 > computeIndex (PixelDiodeTree::IndexType sub_matrix_idx, PixelDiodeTree::IndexType diode_idx, const Vector2D &pos) const
 Compute the 2D index (row, column) of a certain diode in a certain sub-matrix. More...
 
Vector2D findFromIdx (const std::array< CellIndexType, 2 > &idx) const
 find a diode by its 2D index (row, column) and compute the position relative to the center of the full diode matrix More...
 
DiodeProxy diodeProxyFromIdx (const std::array< CellIndexType, 2 > &idx) const
 find a diode by its 2D index (row, column) the returned proxy allows to compute the position and provides access to the parameters of the diode More...
 
DiodeProxyWithPosition diodeProxyFromIdxCachePosition (const std::array< CellIndexType, 2 > &idx) const
 find a diode by its 2D index (row, column) and compute the position of the diode the returned proxy caches the diode position and provides access to its parameters. More...
 
std::array< CellIndexType, 2 > findFromPos (const Vector2D &pos) const
 Find a diode by the position relative to the center of the full diode matrix and compute its 2D index (row, column) More...
 
DiodeProxy diodeProxyFromPos (const Vector2D &pos) const
 Find a diode by the position relative to the center of the full diode matrix. More...
 
bool empty () const
 Return true if no sub-matrices are defined, indicates an invalid state. More...
 
const Vector2DtotalWidth () const
 Return the total width of the diode matrix. More...
 
std::string debugStringRepr () const
 Dump the diode tree structure into a string. More...
 
AttributeType attribute (IndexType idx) const
 Get the attribute associated to a sub-matrix. More...
 
void setAttribute (IndexType idx, AttributeType new_attribute)
 Set the attribute associated to a sub-matrix. More...
 
unsigned int cloneSingleSplitsToUnusedHalf ()
 Clone half with valid split indices to "unused" half with invalid split indices. More...
 
PixelDiodeTree::Vector2D computeTolerance (const std::array< PixelDiodeTree::CellIndexType, 2 > &matrix_dim) const
 Compute tolerance to ensure that a position is within the expected cell Due to limited floating point precision, positions may only yield the expected pixel index if they are not closer to the edge of the matrix or cell than this tolerance. More...
 
void computeMatrixCorner (const std::array< PixelDiodeTree::CellIndexType, 2 > &matrix_dim)
 Compute the effective maximum lower and upper corner positions of the matrix. More...
 
bool isInsideMatrix (const std::array< PixelDiodeTree::IndexType, 2 > &idx) const
 Return true if the given index describes a valid location inside the matrix. More...
 
bool isInsideMatrix (const Amg::Vector2D &local_position) const
 Test whether the given local position is well within the matrix. More...
 

Static Public Member Functions

template<typename T >
static constexpr bool validCellIndex (T cell_index)
 Test whether the cell_index either row or column index could be valid The index may still be outside the matrix. More...
 
template<typename T >
static constexpr std::array< PixelDiodeTree::CellIndexType, 2 > makeCellIndex (T local_x_idx, T local_y_idx)
 Create a 2D cell index from the indices in local-x (phi, row) and local-y (eta, column) direction. More...
 
template<typename T_CellID >
static void neighboursOfCell (const std::array< CellIndexType, 2 > &idx, const std::array< CellIndexType, 2 > &max_idx, std::vector< T_CellID > &neighbours)
 Get indices of all adjacent cells. More...
 

Static Public Attributes

static constexpr IndexType s_invalid = std::numeric_limits<IndexType>::min()
 

Protected Attributes

std::vector< std::array< CellIndexType, 2 > > m_idxSplit
 
std::vector< Vector2Dm_posSplit
 
std::vector< AttributeTypem_attribute
 
std::vector< std::array< IndexType, 4 > > m_subMatrixIndex
 
DiodeParam m_diodeParam
 
std::array< Vector2D, 2 > m_matrixCorner {}
 
std::array< CellIndexType, 2 > m_matrixDim {}
 

Detailed Description

Tree structure to find the position, index or pitch of a pixel on a semi-regular grid The grid is considered regular if sub grids resulting from consecutive splits in local-x and local-y direction have identical pitch.

Definition at line 32 of file PixelDiodeTree.h.

Member Typedef Documentation

◆ AttributeType

Definition at line 39 of file PixelDiodeTree.h.

◆ CellIndexType

Definition at line 37 of file PixelDiodeTree.h.

◆ FloatType

using InDetDD::PixelDiodeTree::FloatType = Amg::Vector2D::Scalar

Definition at line 36 of file PixelDiodeTree.h.

◆ IndexType

Definition at line 38 of file PixelDiodeTree.h.

◆ Vector2D

Definition at line 35 of file PixelDiodeTree.h.

Constructor & Destructor Documentation

◆ PixelDiodeTree()

InDetDD::PixelDiodeTree::PixelDiodeTree ( const Vector2D total_width)
inline

Definition at line 61 of file PixelDiodeTree.h.

61  {
62  m_diodeParam.addDiode(total_width); // dummy diode representing the total width of the entire diode matrix
63  }

Member Function Documentation

◆ addDiode()

unsigned int InDetDD::PixelDiodeTree::addDiode ( const Vector2D width,
AttributeType  attribute 
)
inline

Definition at line 66 of file PixelDiodeTree.h.

66  {
67  assert( m_diodeParam.m_width.size()>0);
69  }

◆ attribute()

AttributeType InDetDD::PixelDiodeTree::attribute ( IndexType  idx) const
inline

Get the attribute associated to a sub-matrix.

Definition at line 328 of file PixelDiodeTree.h.

328  {
329  return m_attribute.at(idx);
330  }

◆ cloneSingleSplitsToUnusedHalf()

unsigned int InDetDD::PixelDiodeTree::cloneSingleSplitsToUnusedHalf ( )

Clone half with valid split indices to "unused" half with invalid split indices.

For splits which only split one of the two axes, half of the sub-matrix indices will be invalid, to ensure that the position and index computation can be carried out also for indices or positions which are not well within the bounds of the matrix, the invalid indices of that half will be overwritten with indices of the half for which the indices are set.

Definition at line 11 of file PixelDiodeTree.cxx.

11  {
12  unsigned int errors=0;
13  constexpr std::array<IndexType,2> axis_offset{1,2};
14  for (std::array<IndexType,4> &a_split : m_subMatrixIndex) {
15  unsigned int n_invalid=0;
16  IndexType good_idx=s_invalid;
17  std::array<std::array<unsigned int,2>,2> n_invalid_halves{};
18  for (unsigned int element_i=0; element_i<a_split.size(); ++element_i) {
19  bool is_invalid = a_split.at(element_i)==s_invalid;
20  unsigned int axis0=element_i/2;
21  unsigned int axis1=element_i%2;
22  n_invalid_halves[0][axis0]+=is_invalid;
23  n_invalid_halves[1][axis1]+=is_invalid;
24  if (is_invalid) ++n_invalid;
25  else { good_idx=a_split[element_i]; }
26  }
27  if (n_invalid==3) {
28  assert( good_idx != s_invalid);
29  for (unsigned int element_i=0; element_i<a_split.size(); ++element_i) {
30  a_split.at(element_i)=good_idx;
31  }
32  }
33  else if (n_invalid==2) {
34  unsigned int element_i=std::numeric_limits<unsigned int>::max();
35  for (unsigned int axis_i=0; axis_i<2; ++axis_i) {
36  for (unsigned int side_i=0; side_i<2; ++side_i) {
37  if (n_invalid_halves[axis_i][side_i]==2 && n_invalid_halves[axis_i][side_i^1]==0) {
38  element_i=axis_offset[axis_i^1]*side_i;
39  IndexType other_element_i = axis_offset[axis_i^1]*(side_i==1 ? -1 : 1);
40  unsigned int element_end_i=element_i+axis_offset[axis_i]*2;
41  for(; element_i<element_end_i; element_i+=axis_offset[axis_i] ) {
42  a_split[ element_i ] = a_split[ element_i + other_element_i] ;
43  }
44  break;
45  }
46  if (element_i != std::numeric_limits<unsigned int>::max()) break;
47  }
48  }
49  if (element_i == std::numeric_limits<unsigned int>::max()) {
50  errors += 2;
51  }
52  }
53  else if (n_invalid!=0) {
54  errors +=2;
55  }
56  }
57 
58  return errors;
59 }

◆ computeIndex()

std::array<CellIndexType,2> InDetDD::PixelDiodeTree::computeIndex ( PixelDiodeTree::IndexType  sub_matrix_idx,
PixelDiodeTree::IndexType  diode_idx,
const Vector2D pos 
) const
inline

Compute the 2D index (row, column) of a certain diode in a certain sub-matrix.

Parameters
sub_matrix_idxthe index of the sub-matrix whose "split-areas" refer to this diode
diode_idxthe index of the diode which gives access to the parameters of the this diode.
posthe position of the diode relative to the center of the full matrix (not sub-matrix).
Returns
the 2D index of the diode (row,column)

Definition at line 162 of file PixelDiodeTree.h.

164  {
165  // pos = (idx - split-index) + 0.5) * pitch + split-position
166  // idx = inr( (pos - split-position)/pitch - 0.5 + split-index + 0.5 (rounding) )
167  std::array<CellIndexType,2> idx;
168  assert( diode_idx>0);
169  assert( static_cast<unsigned int>(diode_idx) < m_diodeParam.m_invWidth.size() ) ;
170  assert( static_cast<unsigned int>(sub_matrix_idx) < m_idxSplit.size() );
171  assert( static_cast<unsigned int>(sub_matrix_idx) < m_posSplit.size() );
172  for (unsigned int axis_i=0; axis_i<2; ++axis_i) {
173  assert( axis_i < m_diodeParam.m_invWidth[diode_idx].size() );
174 
175  idx[axis_i] = intFloor<CellIndexType>( m_idxSplit[sub_matrix_idx][axis_i]
176  + (pos[axis_i]-m_posSplit[sub_matrix_idx][axis_i])
177  * m_diodeParam.m_invWidth[diode_idx][axis_i]);
178  };
179  return idx;
180  }

◆ computeMatrixCorner()

void InDetDD::PixelDiodeTree::computeMatrixCorner ( const std::array< PixelDiodeTree::CellIndexType, 2 > &  matrix_dim)

Compute the effective maximum lower and upper corner positions of the matrix.

The matrix will be shrunk to ensure that positions within the corners will yield valid indices. Note: needs to be called after the tree has been constructed, otherwise the isInsideMatrix calls will be undefined.

Definition at line 61 of file PixelDiodeTree.cxx.

61  {
62  assert( matrix_dim[0]>0 && matrix_dim[1]>0);
63  m_matrixDim=matrix_dim;
65  {
66  DiodeProxyWithPosition lower_corner_proxy(diodeProxyFromIdxCachePosition(std::array<CellIndexType,2> {}));
67  m_matrixCorner[0]=lower_corner_proxy.position() - lower_corner_proxy.width()*.5;
68  for (unsigned int axis_i=0; axis_i<2; ++axis_i) {
69  m_matrixCorner[0][axis_i] += tolerance[axis_i];
70  }
71  }
72 
73  {
74  DiodeProxyWithPosition upper_corner_proxy(diodeProxyFromIdxCachePosition(std::array<PixelDiodeTree::CellIndexType,2> {matrix_dim[0]-1,
75  matrix_dim[1]-1}));
76  m_matrixCorner[1]=upper_corner_proxy.position() + upper_corner_proxy.width()*.5 ;
77  for (unsigned int axis_i=0; axis_i<2; ++axis_i) {
78  m_matrixCorner[1][axis_i] -= tolerance[axis_i];
79  }
80  }
82  throw std::logic_error("Logic error! Matrix corner positions do not yield valid indices for this matrix!");
83  }
84 }

◆ computePosition()

Vector2D InDetDD::PixelDiodeTree::computePosition ( PixelDiodeTree::IndexType  sub_matrix_idx,
PixelDiodeTree::IndexType  diode_idx,
const std::array< CellIndexType, 2 > &  idx 
) const
inline

Compute the position of a certain diode in a certain sub-matrix.

Parameters
sub_matrix_idxthe index of the sub-matrix whose "split-areas" refer to this diode
diode_idxthe index of the diode which gives access to the parameters of the this diode.
idxthe 2D index of the diode (row,column)
Returns
the position of the diode relative to the center of the full matrix (not sub-matrix)

Definition at line 140 of file PixelDiodeTree.h.

142  {
143  // pos = (idx - split-index) + 0.5) * pitch + split-position
144  Vector2D pos;
145  assert( diode_idx>0);
146  assert( static_cast<unsigned int>(diode_idx) < m_diodeParam.m_width.size() ) ;
147  assert( static_cast<unsigned int>(sub_matrix_idx) < m_idxSplit.size() );
148  for (unsigned int axis_i=0; axis_i<2; ++axis_i) {
149  assert( axis_i < m_diodeParam.m_width[diode_idx].size() );
150  pos[axis_i] = ( m_posSplit[sub_matrix_idx][axis_i]
151  + ((idx[axis_i]-m_idxSplit[sub_matrix_idx][axis_i])
152  + static_cast<FloatType>(.5)) * m_diodeParam.m_width[diode_idx][axis_i]);
153  };
154  return pos;
155  }

◆ computeTolerance()

PixelDiodeTree::Vector2D InDetDD::PixelDiodeTree::computeTolerance ( const std::array< PixelDiodeTree::CellIndexType, 2 > &  matrix_dim) const

Compute tolerance to ensure that a position is within the expected cell Due to limited floating point precision, positions may only yield the expected pixel index if they are not closer to the edge of the matrix or cell than this tolerance.

Definition at line 86 of file PixelDiodeTree.cxx.

86  {
88  for (unsigned int axis_i=0; axis_i<2; ++axis_i) {
89  assert( matrix_dim[axis_i]>0 &&
90  static_cast<unsigned int>(std::abs(matrix_dim[axis_i])) < std::numeric_limits<unsigned int>::max());
91  unsigned int bits_i=0;
92  for (; bits_i<16 && 1u<<bits_i < static_cast<unsigned int>(matrix_dim[axis_i])*3; ++bits_i);
94  }
95  return tolerance;
96 }

◆ debugStringRepr()

std::string InDetDD::PixelDiodeTree::debugStringRepr ( ) const

Dump the diode tree structure into a string.

Definition at line 98 of file PixelDiodeTree.cxx.

98  {
99  std::stringstream out;
100  if (!m_diodeParam.m_width.empty()) {
101  if ( m_idxSplit.size() != m_posSplit.size()
102  || m_idxSplit.size() != m_subMatrixIndex.size()
103  || m_idxSplit.size() != m_attribute.size()
104  || m_diodeParam.m_width.size() != m_diodeParam.m_invWidth.size()
105  || m_diodeParam.m_width.size() != m_diodeParam.m_attribute.size()) {
106  // should never happer
107  out << "PixelDiodeTree is inconsistent. Expected identical number of elements but has the following "
108  << " container sizes: index-split points : " << m_idxSplit.size()
109  << " position split points : " << m_posSplit.size()
110  << " submatrices : " << m_subMatrixIndex.size()
111  << " attributes : " << m_attribute.size()
112  << "; diodes : width : " << m_diodeParam.m_width.size()
113  << " inverted width : " << m_diodeParam.m_invWidth.size()
114  << " attributes : " << m_diodeParam.m_attribute.size()
115  << ".\n";
116  }
117  else {
118  out << "PixelDiodeTree total width : " << m_diodeParam.m_width[0][0] << "x" << m_diodeParam.m_width[0][1] << " mm^2" << "\n:";
119  std::vector<std::pair<IndexType,unsigned int> > submatrix_stack;
120  submatrix_stack.push_back(std::make_pair(0u,2u));
121  while (!submatrix_stack.empty()) {
122  auto [submatrix_idx, margin] = submatrix_stack.back();
123  submatrix_stack.pop_back();
124  out << std::setw(margin) << ' ';
125  if (submatrix_idx < 0) {
126  if (submatrix_idx!=s_invalid) {
127  unsigned int diode_idx=std::abs(submatrix_idx);
128  if (diode_idx<m_diodeParam.m_width.size()) {
129  out << " diode width " << m_diodeParam.m_width[diode_idx][0] << " x " << m_diodeParam.m_width[diode_idx][1]
130  << " attribute " << std::hex << m_diodeParam.m_attribute[diode_idx] << std::dec << "\n";
131  }
132  }
133  }
134  else if (static_cast<std::size_t>(submatrix_idx) >= m_idxSplit.size()) {
135  out << "Invalid sub-matrix index : " << submatrix_idx << "\n";
136  }
137  else {
138  out << " split at (row,col) " << m_idxSplit[submatrix_idx][0] << " " << m_idxSplit[submatrix_idx][1]
139  << " , position (local-x/-y) " << m_posSplit[submatrix_idx][0] << " " << m_posSplit[submatrix_idx][1]
140  << " attribute " << std::hex << m_attribute[submatrix_idx] << std::dec
141  << " sub-matrices (diodes): ";
142  for (unsigned int split_i=0; split_i<m_subMatrixIndex[submatrix_idx].size(); ++split_i) {
143  out << (split_i==2 ? " | " : " ");
144  if (m_subMatrixIndex[submatrix_idx][split_i] == s_invalid) {
145  out << "-";
146  }
147  else {
148  out << m_subMatrixIndex[submatrix_idx][split_i];
149  }
150  }
151  out << "\n";
152  for (std::array<IndexType,4>::const_reverse_iterator iter = m_subMatrixIndex[submatrix_idx].rbegin();
153  iter != m_subMatrixIndex[submatrix_idx].rend();
154  ++iter) {
155  if (*iter != s_invalid) {
156  submatrix_stack.push_back( std::make_pair( *iter, margin+2));
157  }
158  }
159  }
160  }
161  }
162  }
163  else {
164  out << "PixelDiodeTree with " << m_subMatrixIndex.size() << " has no diodes." << "\n";
165  }
166  return out.str();
167 }

◆ diodeProxyFromIdx()

DiodeProxy InDetDD::PixelDiodeTree::diodeProxyFromIdx ( const std::array< CellIndexType, 2 > &  idx) const
inline

find a diode by its 2D index (row, column) the returned proxy allows to compute the position and provides access to the parameters of the diode

Definition at line 270 of file PixelDiodeTree.h.

270  {
271  auto [sub_matrix_idx,diode_idx, submatrix_i] = findFromT(idx,m_idxSplit);
272  return DiodeProxy{this, sub_matrix_idx, diode_idx};
273  }

◆ diodeProxyFromIdxCachePosition()

DiodeProxyWithPosition InDetDD::PixelDiodeTree::diodeProxyFromIdxCachePosition ( const std::array< CellIndexType, 2 > &  idx) const
inline

find a diode by its 2D index (row, column) and compute the position of the diode the returned proxy caches the diode position and provides access to its parameters.

Definition at line 276 of file PixelDiodeTree.h.

276  {
277  auto [sub_matrix_idx,diode_idx, submatrix_i] = findFromT(idx,m_idxSplit);
278  DiodeProxyWithPosition proxy(this, sub_matrix_idx, diode_idx, computePosition(sub_matrix_idx, diode_idx, idx));
279  return proxy;
280  }

◆ diodeProxyFromPos()

DiodeProxy InDetDD::PixelDiodeTree::diodeProxyFromPos ( const Vector2D pos) const
inline

Find a diode by the position relative to the center of the full diode matrix.

The returned proxy allows to compute the 2D index (row, column) and provides access to the parameters of the diode

Definition at line 288 of file PixelDiodeTree.h.

288  {
289  auto [sub_matrix_idx,diode_idx, submatrix_i] = findFromT(pos,m_posSplit);
290  return DiodeProxy{this, sub_matrix_idx, diode_idx};
291  }

◆ empty()

bool InDetDD::PixelDiodeTree::empty ( ) const
inline

Return true if no sub-matrices are defined, indicates an invalid state.

Definition at line 294 of file PixelDiodeTree.h.

294 { return m_subMatrixIndex.empty(); }

◆ findFromIdx()

Vector2D InDetDD::PixelDiodeTree::findFromIdx ( const std::array< CellIndexType, 2 > &  idx) const
inline

find a diode by its 2D index (row, column) and compute the position relative to the center of the full diode matrix

Definition at line 264 of file PixelDiodeTree.h.

264  {
265  auto [sub_matrix_idx,diode_idx, submatrix_i] = findFromT(idx,m_idxSplit);
266  return computePosition(sub_matrix_idx, diode_idx,idx);
267  }

◆ findFromPos()

std::array<CellIndexType,2> InDetDD::PixelDiodeTree::findFromPos ( const Vector2D pos) const
inline

Find a diode by the position relative to the center of the full diode matrix and compute its 2D index (row, column)

Definition at line 282 of file PixelDiodeTree.h.

282  {
283  auto [sub_matrix_idx,diode_idx, submatrix_i] = findFromT(pos,m_posSplit);
284  return computeIndex(sub_matrix_idx,diode_idx,pos);
285  }

◆ findFromT()

template<typename T >
std::tuple<IndexType,IndexType, IndexType> InDetDD::PixelDiodeTree::findFromT ( const T &  val,
const std::vector< T > &  split 
) const
inline

helper template to find the final node in a quad tree.

Definition at line 119 of file PixelDiodeTree.h.

120  {
121  IndexType sub_matrix_idx=0;
122  IndexType last_sub_matrix_idx=0;
123  unsigned int submatrix_i=0;
124  while (sub_matrix_idx>=0) {
125  assert( static_cast<std::size_t>(sub_matrix_idx) < split.size() );
126  last_sub_matrix_idx=sub_matrix_idx;
127  submatrix_i = (val[0] >= split[sub_matrix_idx][0]) + (val[1] >= split[sub_matrix_idx][1])*2;
128  sub_matrix_idx=m_subMatrixIndex[sub_matrix_idx][submatrix_i];
129  }
130  assert( sub_matrix_idx != s_invalid);
131  assert( static_cast<size_t>(std::abs(sub_matrix_idx)) < m_diodeParam.m_width.size() );
132  return std::make_tuple(last_sub_matrix_idx, std::abs(sub_matrix_idx), submatrix_i);
133  }

◆ isInsideMatrix() [1/2]

bool InDetDD::PixelDiodeTree::isInsideMatrix ( const Amg::Vector2D local_position) const
inline

Test whether the given local position is well within the matrix.

Definition at line 364 of file PixelDiodeTree.h.

364  {
365  // corner positions are moved to the inside of the matrix to account for floating point
366  // tolerances so >= && <= means "well" inside the matrix.
367  return ( local_position[0]>=m_matrixCorner[0][0] && local_position[0]<=m_matrixCorner[1][0]
368  && local_position[1]>=m_matrixCorner[0][1] && local_position[1]<=m_matrixCorner[1][1]);
369  }

◆ isInsideMatrix() [2/2]

bool InDetDD::PixelDiodeTree::isInsideMatrix ( const std::array< PixelDiodeTree::IndexType, 2 > &  idx) const
inline

Return true if the given index describes a valid location inside the matrix.

Definition at line 359 of file PixelDiodeTree.h.

359  {
360  return idx[0]>=0 && idx[1]>=0 && idx[0] < m_matrixDim[0] && idx[1] < m_matrixDim[1];
361  }

◆ makeCellIndex()

template<typename T >
static constexpr std::array<PixelDiodeTree::CellIndexType,2> InDetDD::PixelDiodeTree::makeCellIndex ( local_x_idx,
local_y_idx 
)
inlinestaticconstexpr

Create a 2D cell index from the indices in local-x (phi, row) and local-y (eta, column) direction.

Definition at line 320 of file PixelDiodeTree.h.

320  {
321  assert( validCellIndex(local_x_idx) && validCellIndex(local_y_idx) );
322  return std::array<PixelDiodeTree::CellIndexType,2>{
323  static_cast<PixelDiodeTree::CellIndexType>(local_x_idx),
324  static_cast<PixelDiodeTree::CellIndexType>(local_y_idx)};
325  }

◆ neighboursOfCell()

template<typename T_CellID >
void InDetDD::PixelDiodeTree::neighboursOfCell ( const std::array< CellIndexType, 2 > &  idx,
const std::array< CellIndexType, 2 > &  max_idx,
std::vector< T_CellID > &  neighbours 
)
static

Get indices of all adjacent cells.

Definition at line 389 of file PixelDiodeTree.h.

391  {
392  neighbours.reserve(8);
393  std::array<std::array<PixelDiodeTree::CellIndexType,2>,2> outer_idx {
394  std::array<PixelDiodeTree::CellIndexType,2>{idx[0]-1,idx[0]+1},
395  std::array<PixelDiodeTree::CellIndexType,2>{idx[1]-1,idx[1]+1}
396  };
397 
398  if (outer_idx[0][0]>=0 && outer_idx[1][0]>=0) neighbours.emplace_back(outer_idx[0][0],outer_idx[1][0]);
399  if ( outer_idx[1][0]>=0) neighbours.emplace_back(idx[0], outer_idx[1][0]);
400  if (outer_idx[0][1]<max_idx[0] && outer_idx[1][0]>=0) neighbours.emplace_back(outer_idx[0][1],outer_idx[1][0]);
401  if (outer_idx[0][1]<max_idx[0]) neighbours.emplace_back(outer_idx[0][1],idx[1]);
402  if (outer_idx[0][1]<max_idx[0] && outer_idx[1][1]<max_idx[1]) neighbours.emplace_back(outer_idx[0][1],outer_idx[1][1]);
403  if ( outer_idx[1][1]<max_idx[1]) neighbours.emplace_back(idx[0], outer_idx[1][1]);
404  if (outer_idx[0][0]>=0 && outer_idx[1][1]<max_idx[1]) neighbours.emplace_back(outer_idx[0][0],outer_idx[1][1]);
405  if (outer_idx[0][0]>=0 ) neighbours.emplace_back(outer_idx[0][0],idx[1]);
406 }

◆ setAttribute()

void InDetDD::PixelDiodeTree::setAttribute ( IndexType  idx,
AttributeType  new_attribute 
)
inline

Set the attribute associated to a sub-matrix.

Parameters
idxthe index of the sub-matrix
new_attributethe new attribute for the sub-matrix

Definition at line 334 of file PixelDiodeTree.h.

334  {
335  m_attribute.at(idx)=new_attribute;
336  }

◆ setDiodeForSubMatrix()

void InDetDD::PixelDiodeTree::setDiodeForSubMatrix ( unsigned int  sub_matrix_idx,
unsigned int  split_i,
unsigned int  diode_idx 
)
inline

Definition at line 79 of file PixelDiodeTree.h.

79  {
80  assert( diode_idx > 0 && diode_idx < std::numeric_limits<IndexType>::max());
81  assert( sub_matrix_idx < m_subMatrixIndex.size());
82  assert( split_i <m_subMatrixIndex[sub_matrix_idx].size() );
83  m_subMatrixIndex.at(sub_matrix_idx)[split_i]=-static_cast<IndexType>(diode_idx);
84  }

◆ split()

unsigned int InDetDD::PixelDiodeTree::split ( const std::array< CellIndexType, 2 > &  idx_split,
const Vector2D pos_split,
AttributeType  an_attribute,
unsigned int  parent_idx = std::numeric_limits<unsigned int>::max(),
unsigned int  split_i = 0 
)
inline

Definition at line 92 of file PixelDiodeTree.h.

96  {
97  assert( m_idxSplit.size() == m_posSplit.size());
98  assert( m_idxSplit.size() == m_subMatrixIndex.size());
99  assert( m_idxSplit.size() == m_attribute.size());
100  unsigned int this_submatrix_idx = m_idxSplit.size();
101  m_idxSplit.push_back(idx_split);
102  m_posSplit.push_back(pos_split);
103  assert( PixelDiodeTree::s_invalid < 0);
104  assert( -static_cast<IndexType>(m_diodeParam.m_width.size()) > PixelDiodeTree::s_invalid);
105  m_subMatrixIndex.push_back(std::array<PixelDiodeTree::IndexType,4>{PixelDiodeTree::s_invalid, PixelDiodeTree::s_invalid,
107  m_attribute.push_back(an_attribute);
108  if (parent_idx != std::numeric_limits<unsigned int>::max()) {
109  assert( split_i < m_subMatrixIndex[parent_idx].size());
110  m_subMatrixIndex.at(parent_idx)[split_i]=this_submatrix_idx;
111  }
112 
113  return this_submatrix_idx;
114  }

◆ totalWidth()

const Vector2D& InDetDD::PixelDiodeTree::totalWidth ( ) const
inline

Return the total width of the diode matrix.

Definition at line 297 of file PixelDiodeTree.h.

297  {
298  // constructor should store total width here, empty means that this diode tree is not properly constructed.
299  assert(!m_diodeParam.m_width.empty());
300  return m_diodeParam.m_width[0];
301  }

◆ validCellIndex()

template<typename T >
static constexpr bool InDetDD::PixelDiodeTree::validCellIndex ( cell_index)
inlinestaticconstexpr

Test whether the cell_index either row or column index could be valid The index may still be outside the matrix.

Definition at line 309 of file PixelDiodeTree.h.

309  {
310  if constexpr( std::is_signed_v<T>) {
312  }
313  else {
315  }
316  }

Member Data Documentation

◆ m_attribute

std::vector<AttributeType> InDetDD::PixelDiodeTree::m_attribute
protected

Definition at line 380 of file PixelDiodeTree.h.

◆ m_diodeParam

DiodeParam InDetDD::PixelDiodeTree::m_diodeParam
protected

Definition at line 383 of file PixelDiodeTree.h.

◆ m_idxSplit

std::vector<std::array<CellIndexType, 2> > InDetDD::PixelDiodeTree::m_idxSplit
protected

Definition at line 378 of file PixelDiodeTree.h.

◆ m_matrixCorner

std::array<Vector2D,2> InDetDD::PixelDiodeTree::m_matrixCorner {}
protected

Definition at line 384 of file PixelDiodeTree.h.

◆ m_matrixDim

std::array<CellIndexType,2> InDetDD::PixelDiodeTree::m_matrixDim {}
protected

Definition at line 385 of file PixelDiodeTree.h.

◆ m_posSplit

std::vector<Vector2D > InDetDD::PixelDiodeTree::m_posSplit
protected

Definition at line 379 of file PixelDiodeTree.h.

◆ m_subMatrixIndex

std::vector<std::array<IndexType, 4> > InDetDD::PixelDiodeTree::m_subMatrixIndex
protected

Definition at line 382 of file PixelDiodeTree.h.

◆ s_invalid

constexpr IndexType InDetDD::PixelDiodeTree::s_invalid = std::numeric_limits<IndexType>::min()
staticconstexpr

Definition at line 40 of file PixelDiodeTree.h.


The documentation for this class was generated from the following files:
createLinkingScheme.iter
iter
Definition: createLinkingScheme.py:62
tolerance
constexpr double tolerance
Definition: runMdtGeoComparison.cxx:104
StateLessPT_NewConfig.proxy
proxy
Definition: StateLessPT_NewConfig.py:407
InDetDD::PixelDiodeTree::findFromPos
std::array< CellIndexType, 2 > findFromPos(const Vector2D &pos) const
Find a diode by the position relative to the center of the full diode matrix and compute its 2D index...
Definition: PixelDiodeTree.h:282
max
constexpr double max()
Definition: ap_fixedTest.cxx:33
min
constexpr double min()
Definition: ap_fixedTest.cxx:26
InDetDD::PixelDiodeTree::diodeProxyFromIdxCachePosition
DiodeProxyWithPosition diodeProxyFromIdxCachePosition(const std::array< CellIndexType, 2 > &idx) const
find a diode by its 2D index (row, column) and compute the position of the diode the returned proxy c...
Definition: PixelDiodeTree.h:276
InDetDD::PixelDiodeTree::validCellIndex
static constexpr bool validCellIndex(T cell_index)
Test whether the cell_index either row or column index could be valid The index may still be outside ...
Definition: PixelDiodeTree.h:309
CaloClusterMLCalib::epsilon
constexpr float epsilon
Definition: CaloClusterMLGaussianMixture.h:16
python.AthDsoLogger.out
out
Definition: AthDsoLogger.py:70
InDetDD::PixelDiodeTree::CellIndexType
int CellIndexType
Definition: PixelDiodeTree.h:37
InDetDD::PixelDiodeTree::m_diodeParam
DiodeParam m_diodeParam
Definition: PixelDiodeTree.h:383
InDetDD::PixelDiodeTree::split
unsigned int split(const std::array< CellIndexType, 2 > &idx_split, const Vector2D &pos_split, AttributeType an_attribute, unsigned int parent_idx=std::numeric_limits< unsigned int >::max(), unsigned int split_i=0)
Definition: PixelDiodeTree.h:92
Trk::u
@ u
Enums for curvilinear frames.
Definition: ParamDefs.h:77
InDetDD::PixelDiodeTree::DiodeParam::m_width
std::vector< Vector2D > m_width
Definition: PixelDiodeTree.h:44
InDetDD::PixelDiodeTree::DiodeParam::m_attribute
std::vector< AttributeType > m_attribute
Definition: PixelDiodeTree.h:46
python.setupRTTAlg.size
int size
Definition: setupRTTAlg.py:39
InDetDD::PixelDiodeTree::DiodeParam::m_invWidth
std::vector< Vector2D > m_invWidth
Definition: PixelDiodeTree.h:45
mergePhysValFiles.errors
list errors
Definition: DataQuality/DataQualityUtils/scripts/mergePhysValFiles.py:42
InDetDD::PixelDiodeTree::computeTolerance
PixelDiodeTree::Vector2D computeTolerance(const std::array< PixelDiodeTree::CellIndexType, 2 > &matrix_dim) const
Compute tolerance to ensure that a position is within the expected cell Due to limited floating point...
Definition: PixelDiodeTree.cxx:86
InDetDD::PixelDiodeTree::FloatType
Amg::Vector2D::Scalar FloatType
Definition: PixelDiodeTree.h:36
InDetDD::PixelDiodeTree::m_idxSplit
std::vector< std::array< CellIndexType, 2 > > m_idxSplit
Definition: PixelDiodeTree.h:378
InDetDD::PixelDiodeTree::computeIndex
std::array< CellIndexType, 2 > computeIndex(PixelDiodeTree::IndexType sub_matrix_idx, PixelDiodeTree::IndexType diode_idx, const Vector2D &pos) const
Compute the 2D index (row, column) of a certain diode in a certain sub-matrix.
Definition: PixelDiodeTree.h:162
InDetDD::PixelDiodeTree::m_posSplit
std::vector< Vector2D > m_posSplit
Definition: PixelDiodeTree.h:379
tolerance
Definition: suep_shower.h:17
InDetDD::PixelDiodeTree::DiodeParam::addDiode
unsigned int addDiode(const Vector2D &width, AttributeType attribute=AttributeType{})
Definition: PixelDiodeTree.h:49
InDetDD::PixelDiodeTree::s_invalid
static constexpr IndexType s_invalid
Definition: PixelDiodeTree.h:40
InDetDD::PixelDiodeTree::attribute
AttributeType attribute(IndexType idx) const
Get the attribute associated to a sub-matrix.
Definition: PixelDiodeTree.h:328
InDetDD::PixelDiodeTree::Vector2D
Amg::Vector2D Vector2D
Definition: PixelDiodeTree.h:35
python.LumiBlobConversion.pos
pos
Definition: LumiBlobConversion.py:16
InDetDD::PixelDiodeTree::isInsideMatrix
bool isInsideMatrix(const std::array< PixelDiodeTree::IndexType, 2 > &idx) const
Return true if the given index describes a valid location inside the matrix.
Definition: PixelDiodeTree.h:359
Base_Fragment.width
width
Definition: Sherpa_i/share/common/Base_Fragment.py:59
Pythia8_RapidityOrderMPI.val
val
Definition: Pythia8_RapidityOrderMPI.py:14
LArNewCalib_DelayDump_OFC_Cali.idx
idx
Definition: LArNewCalib_DelayDump_OFC_Cali.py:69
InDetDD::PixelDiodeTree::findFromT
std::tuple< IndexType, IndexType, IndexType > findFromT(const T &val, const std::vector< T > &split) const
helper template to find the final node in a quad tree.
Definition: PixelDiodeTree.h:119
InDetDD::PixelDiodeTree::m_matrixDim
std::array< CellIndexType, 2 > m_matrixDim
Definition: PixelDiodeTree.h:385
InDetDD::PixelDiodeTree::computePosition
Vector2D computePosition(PixelDiodeTree::IndexType sub_matrix_idx, PixelDiodeTree::IndexType diode_idx, const std::array< CellIndexType, 2 > &idx) const
Compute the position of a certain diode in a certain sub-matrix.
Definition: PixelDiodeTree.h:140
InDetDD::PixelDiodeTree::m_attribute
std::vector< AttributeType > m_attribute
Definition: PixelDiodeTree.h:380
InDetDD::PixelDiodeTree::m_subMatrixIndex
std::vector< std::array< IndexType, 4 > > m_subMatrixIndex
Definition: PixelDiodeTree.h:382
columnar::rbegin
auto rbegin() const noexcept
Definition: ObjectRange.h:162
InDetDD::PixelDiodeTree::IndexType
int IndexType
Definition: PixelDiodeTree.h:38
InDetDD::PixelDiodeTree::m_matrixCorner
std::array< Vector2D, 2 > m_matrixCorner
Definition: PixelDiodeTree.h:384