ATLAS Offline Software
Loading...
Searching...
No Matches
StripModuleHelper.h
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3 */
4#ifndef INDET_STRIPMODULEHELPER_H
5#define INDET_STRIPMODULEHELPER_H
6
8#include <cassert>
9#include <array>
10#include <stdexcept>
11#include <algorithm>
12#include "ModuleKeyHelper.h"
13
14namespace InDet {
17 class StripModuleHelper : public ModuleKeyHelper<unsigned short, // key type
18 12, // bits for rows
19 0, // bits for columns
20 0 // bits for chip
21 > {
22 public:
23
24
25 // mask with every bit set for all chips, columns, rows, but the mask index bits.
26 static constexpr unsigned int getStripMask() { return MaskUtils::createMask<0,ROW_BITS+CHIP_BITS>(); }
27 // mask with row and column bits set to zero.
28 static constexpr unsigned int getChipMask() { return MaskUtils::createMask<ROW_BITS,ROW_BITS+CHIP_BITS>(); }
29
30
32 {
33 const InDetDD::SCT_ModuleSideDesign *stripModuleDesign = dynamic_cast<const InDetDD::SCT_ModuleSideDesign *>(&design);
34 if (stripModuleDesign) {
35 m_rows = stripModuleDesign->cells(); // strips
36 m_columns=1u;
37 }
38 }
39 static constexpr unsigned int N_MASKS = 1;
40 static constexpr unsigned int nMasks() { return N_MASKS; }
41 std::array<unsigned int, N_MASKS> masks() const {
42 return std::array<unsigned int,N_MASKS> {
44 };
45 }
46
47 operator bool () const { return m_rows>0; }
48
49 unsigned int columns() const { return m_columns; }
50 unsigned int rows() const { return m_rows; }
51 static constexpr unsigned int columnsPerCircuit() { return 1u; }
52 unsigned int rowsPerCircuit() const { return m_rows; }
53 static constexpr unsigned int circuitsPerColumn() { return 1u; }
54 static constexpr unsigned int circuitsPerRow() { return 1u; }
55
56 static constexpr unsigned int columnsPerMask([[maybe_unused]] unsigned int mask_idx) { return 1u;}
57
63 KEY_TYPE hardwareCoordinates(unsigned int row, unsigned int column) const {
64 unsigned int chip =0;
65 if (circuitsPerColumn()>1) {
66 chip += (row/rowsPerCircuit()) * circuitsPerRow();
67 row = row % rowsPerCircuit();
68 if (chip>0) {
69 row = rowsPerCircuit() - row -1;
70 column = columns() - column -1;
71 }
72 }
73 if (circuitsPerRow()>1) {
74 chip += column/columnsPerCircuit();
75 column = column%columnsPerCircuit();
76 }
77 return makeKey(0u, chip, column, row);
78 }
79
83 std::pair<unsigned int,unsigned int> offlineCoordinates(unsigned int key) const {
84 unsigned int chip = getChip(key);
85 unsigned int column = getColumn(key);
86 unsigned int row = getRow(key);
87 // handle special values
88 // used for merging
89 // should not occur for strips
90 if (row == getLimitRowMax()) {
91 row=rowsPerCircuit()-1;
92 }
93 if (row == rowsPerCircuit()) {
94 column+=1u;
95 row=0u;
96 }
97
98 column+= columnsPerCircuit() * (chip%circuitsPerRow());
99 if (chip>=circuitsPerRow()) {
100 column=columns() - column -1;
101 row=rowsPerCircuit() - row -1;
102 row+=rowsPerCircuit() * (chip/circuitsPerRow());
103 }
104 if (row>nSensorRows() || column>nSensorColumns()) {
105 throw std::runtime_error("Invvalid offline coordinates");
106 }
107 return std::make_pair(row,column);
108 }
109
112 unsigned int nCells() const {
113 return m_columns * m_rows;
114 }
115
117 unsigned int nSensorColumns() const {
118 return m_columns;
119 }
120
122 unsigned int nSensorRows() const {
123 return m_rows;
124 }
125
128 unsigned int nElements([[maybe_unused]] unsigned int mask_i) const {
129 assert( mask_i==0);
130 return nCells();
131 }
132
137 std::array<unsigned int,4> offlineRange(const std::pair<unsigned int,unsigned int> &range) const {
138 if (range.first != range.second) {
139 // if (getRow(range.first) !=0) {
140 // throw std::runtime_error("invalid key");
141 // };
142
143 std::pair<unsigned int, unsigned int> start=offlineCoordinates(range.first);
144 std::pair<unsigned int, unsigned int> end=offlineCoordinates(range.second);
145 return std::array<unsigned int,4>{ std::min(start.first, end.first), std::max(start.first, end.first)+1,
146 std::min(start.second, end.second), std::max(start.second,end.second)+1};
147 }
148 else {
149 std::pair<unsigned int, unsigned int> start=offlineCoordinates(range.first);
150 return std::array<unsigned int,4>{ start.first, start.first+1,
151 start.second, start.second+1 };
152 }
153 }
154
155 static constexpr bool swapOfflineRowsColumns() { return false;}
156 private:
157
158 unsigned short m_rows = 0;
159 unsigned short m_columns = 0;
160 };
161}
162#endif
Base class for the SCT module side design, extended by the Forward and Barrel module design.
int cells() const
number of readout stips within module side:
Base class for the detector design classes for Pixel and SCT.
static constexpr unsigned int circuitsPerColumn()
std::array< unsigned int, N_MASKS > masks() const
static constexpr unsigned int columnsPerMask(unsigned int mask_idx)
unsigned int nCells() const
Return the total number strips of this module.
unsigned int rows() const
std::array< unsigned int, 4 > offlineRange(const std::pair< unsigned int, unsigned int > &range) const
Convenience function to return offline column and row ranges matching the defect-area of the given ke...
unsigned int nSensorRows() const
Number of offline rows aka.
unsigned int nSensorColumns() const
Number of offline columns aka.
StripModuleHelper(const InDetDD::SiDetectorDesign &design)
static constexpr unsigned int N_MASKS
static constexpr unsigned int getChipMask()
unsigned int rowsPerCircuit() const
unsigned int columns() const
KEY_TYPE hardwareCoordinates(unsigned int row, unsigned int column) const
Compute "hardware" coordinates from offline coordinates.
static constexpr unsigned int circuitsPerRow()
unsigned int nElements(unsigned int mask_i) const
return the maximum number of unique mask (or group) defects per module.
static constexpr unsigned int getStripMask()
static constexpr unsigned int nMasks()
std::pair< unsigned int, unsigned int > offlineCoordinates(unsigned int key) const
compute offline coordinates from "hardware" coordinates
static constexpr bool swapOfflineRowsColumns()
static constexpr unsigned int columnsPerCircuit()
static consteval T createMask()
Convenience method to create a mask for which exactly one contiguous sequence of bits is set to 1.
Primary Vertex Finder.
Helper class to create keys for defects described by chip, column and row indices,...
static constexpr unsigned short makeKey(bool is_range, unsigned int chip, unsigned int col, unsigned int row=0u)
static constexpr unsigned short getRow(unsigned short key)
static constexpr unsigned short getChip(unsigned short key)
static constexpr unsigned short getColumn(unsigned short key)
static constexpr unsigned short getLimitRowMax()