ATLAS Offline Software
Loading...
Searching...
No Matches
PixelGeoUtils.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3 */
7#include "PixelGeoUtils.h"
9
10namespace InDetDD {
11namespace detail {
12
14 const std::array<int,kNDirections> &circuits,
15 const std::array<int,kNDirections> &dimPerCircuit,
16 const std::array<std::array<double,kNDirections>,kNPixelLocations> &pitch,
17 InDetDD::detail::FENumbering fe_numbering) {
18
19 // helper function to associate correct diode type and front-end number to sub-matrices and diodes
20 // in the diode tree as attributes.
21 auto computeAttribute = [
22 &pitch=pitch[InDetDD::detail::kCentral],
23 &circuits,
24 &dimPerCircuit,
25 fe_numbering
26 ](const std::array<PixelDiodeTree::IndexType,2> &split_idx,
27 const PixelDiodeTree::Vector2D &diode_width,
28 [[maybe_unused]] const std::array<bool,4> &ganged,
29 [[maybe_unused]] unsigned int split_i,
30 PixelDiodeTree::AttributeType current_matrix_attribute,
31 PixelDiodeTree::AttributeType current_diode_attribute)
32 -> std::tuple<PixelDiodeTree::AttributeType,PixelDiodeTree::AttributeType>
33 {
34 // split_i defines which of the 4 areas the diode belongs to : 2 | 3 ^
35 // ----- | local-y (chip-columns)
36 // 0 | 1 |
37 // ---> local-x (chip-rows)
38 //
39 // split_idx the absolute index at which this sub-matrix is split into 4 sub-sub-matrices
40 // diode_width the diode pitch in both directions
41 // ganged ganged[0],ganged[1] whether the pixel diode is ganged in the corresponding direction
42 // ganged[2],ganged[3] whether the diode is inside (true) or outside the dead zone
43 // where ganged[2] denotes the flag in local-x and ganged[3] in local-y direction
44 // current_matrix_attribute the default attribute for the unsplit sub-matrix assigned by the builder
45 // current_diode_attribute the default attribute assigned to the current diode associated to the split
46 // area specified by split_i
47 // return new matrix attribute, new diode attribute
48
49 // if the pixel is significantly wider in one direction consider the pixel to be long
50 // or if wider in both directions large
51 assert(split_idx[0]>=0 && split_idx[1]>=0);
52 std::array<int,2> chip_idx{split_idx[0]/dimPerCircuit[InDetDD::detail::kPhi], split_idx[1]/dimPerCircuit[InDetDD::detail::kEta]};
53
54 unsigned int n_large_dimensions = ( (std::abs(diode_width[0]-pitch[InDetDD::detail::kPhi])>pitch[InDetDD::detail::kPhi]*.25)
55 +(std::abs(diode_width[1]-pitch[InDetDD::detail::kEta])>pitch[InDetDD::detail::kEta]*.25));
56 switch (n_large_dimensions) {
57 case 1:
59 break;
60 case 2:
62 break;
63 default:
65 }
66
67 // FEI3 front-end numbering scheme
68 // if there is a single row just the chip-column (local-y, eta)
69 // if there are two rows: top row chip-column starting from the opposite end; bottom row: chip column + chips per top row
70 // ^ 0 |.. |n/2-1
71 // local-x | --------------- [swapped axis direction to fit into fewer lines]
72 // /phi/row | n-1 |... |n/2
73 // --> local-y (chip-column, eta)
74 current_matrix_attribute
75 = InDetDD::detail::makeAttributeType( chip_idx[0] > 0
76 ? circuits[InDetDD::detail::kEta] - chip_idx[1] - 1
77 : (circuits[InDetDD::detail::kPhi]-1) * circuits[InDetDD::detail::kEta] + chip_idx[1]);
78
79 switch (fe_numbering) {
81 // for even phi Run <=3 endcap modules the numbering is mirrored
82 if (circuits[InDetDD::detail::kPhi] == 2) {
83 current_matrix_attribute = circuits[InDetDD::detail::kEta]- (current_matrix_attribute % circuits[InDetDD::detail::kEta]) -1
84 + ((current_matrix_attribute / circuits[InDetDD::detail::kEta]) ^ 1) * circuits[InDetDD::detail::kEta];
85 }
86 break;
87 }
88 default:
89 break;
90 }
91
92 return std::make_tuple(current_matrix_attribute, current_diode_attribute);
93 };
94
95 unsigned int nEtaLongEnd = pitch[InDetDD::detail::kOuterEdge][InDetDD::detail::kEta]>0. ? 1u : 0u;
96 unsigned int nEtaLong = pitch[InDetDD::detail::kInnerEdge][InDetDD::detail::kEta]>0. ? 1u : 0u;
97 PixelDiodeTree diode_tree
98 = createPixelDiodeTree(std::array<unsigned int,2>{static_cast<unsigned int>(circuits[InDetDD::detail::kPhi]),
99 static_cast<unsigned int>(circuits[InDetDD::detail::kEta])},
100 std::array<unsigned int,2>{static_cast<unsigned int>(dimPerCircuit[InDetDD::detail::kPhi]),
101 static_cast<unsigned int>(dimPerCircuit[InDetDD::detail::kEta])},
103 pitch[InDetDD::detail::kCentral][InDetDD::detail::kEta]}, // regular ptich
104 std::array<std::array<unsigned int,2>, 2>{ std::array<unsigned int,2>{0u,nEtaLongEnd}, // outer edge in pixels (correct?)
105 std::array<unsigned int,2>{0u,nEtaLong}}, // inner edge in pixels (correct?)
106 std::array<PixelDiodeTree::Vector2D,2>{PixelDiodeTree::Vector2D{0.,
110 },
111 std::array<std::array<unsigned int,2>, 2>{ std::array<unsigned int,2>{0u,0u}, // @TODO add dead zone for run1-3 pixels
112 std::array<unsigned int,2>{0u,0u} // @TODO add dead zone for run1-3 pixels
113 },
114 computeAttribute,
115 nullptr);
116 GEO_MSG_DEBUG( "module " << " " << circuits[InDetDD::detail::kPhi] << "x" << circuits[InDetDD::detail::kEta] << " "
117 << dimPerCircuit[InDetDD::detail::kPhi] << " " << dimPerCircuit[InDetDD::detail::kEta] << ":\n"
118 << " pitch: regular " << pitch[InDetDD::detail::kCentral][InDetDD::detail::kPhi]
121 << diode_tree.debugStringRepr());
122 return diode_tree;
123}
124}
125}
#define GEO_MSG_DEBUG(body)
Tree structure to find the position, index or pitch of a pixel on a semi-regular grid The grid is con...
std::string debugStringRepr() const
Dump the diode tree structure into a string.
InDetDD::PixelDiodeTree::AttributeType makeAttributeType(T val)
convenience method to convert the given value into an attribute
Message Stream Member.
PixelDiodeTree createPixelDiodeTree(const std::array< unsigned int, 2 > &chip_dim, const std::array< unsigned int, 2 > &chip_matrix_dim, const PixelDiodeTree::Vector2D &pitch, const std::array< std::array< unsigned int, 2 >, 2 > &edge_dim, const std::array< PixelDiodeTree::Vector2D, 2 > &edge_pitch, const std::array< std::array< unsigned int, 2 >, 2 > &dead_zone, const AttributeRefiner &func_compute_attribute, std::ostream *debug_out=nullptr)
Create a pixel diode tree.
PixelDiodeTree make(InDetDD::PixelReadoutTechnology readoutTechnology, const std::array< int, kNDirections > &circuits, const std::array< int, kNDirections > &dimPerCircuit, const std::array< std::array< double, kNDirections >, kNPixelLocations > &pitch, FENumbering fe_numbering)