ATLAS Offline Software
Loading...
Searching...
No Matches
StripDefectsEmulatorAlg.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_StripDefectsEmulatorAlg_H
5#define InDet_StripDefectsEmulatorAlg_H
6
12
13#include <utility>
14
15namespace InDet {
16
17 template <>
19
20 using ID_Helper = const SCT_ID*;
21
24 struct IDAdapter {
26 static const std::vector<int> s_dummyvector;
27
28 IDAdapter(ID_Helper helper) : m_idHelper(helper) {}
29 int row_index(const Identifier &rdoID) const { return m_idHelper->strip(rdoID); }
30 int col_index(const Identifier &rdoID) const { return m_idHelper->row(rdoID); }
31 template <typename T_ModuleHelper>
32 std::unique_ptr<SCT3_RawData> createNoiseHit(const T_ModuleHelper &helper, const Identifier &identifier, unsigned int cell_idx, unsigned int tot) {
33 unsigned int row_aka_phi=cell_idx % helper.rows();
34 unsigned int col_aka_eta=cell_idx / helper.rows();
35 constexpr unsigned int group_size =1u;
36 constexpr unsigned int errors=0u;
37 return std::make_unique<SCT3_RawData>( m_idHelper->strip_id(identifier,row_aka_phi, col_aka_eta),
38 makeStripWord( /*time bin */ tot, /*stripIn11bits*/ row_aka_phi, group_size, errors ),
40 }
41
44 unsigned int cloneOrRejectHit( const StripModuleHelper &module_helper,
45 const StripEmulatedDefects &emulated_defects,
46 unsigned int idHash,
47 unsigned int row_idx_aka_phi,
48 unsigned int col_idx_aka_eta,
49 const SCT_RDORawData &rdo,
51 unsigned int n_new=0u;
52 assert( rdo.getGroupSize() > 0);
53 // search for all defects starting from the last strip in the group (search is performed in descending order)
54 StripModuleHelper::KEY_TYPE rdo_end_key = module_helper.hardwareCoordinates(row_idx_aka_phi+rdo.getGroupSize()-1, col_idx_aka_eta);
55 auto [defect_iter, end_iter] =emulated_defects.lower_bound(idHash, rdo_end_key);
56
57 // A) 0 defect overlapping with strip group
58 // => lower_bound(strip+group_size()-1) < strip-mask+1 -> clone
59 // B) 1 defect overlapping
60 // => lower_bound(strip+group_size()-1) < strip >= strip-mask+1 -> hit[strip .. defect-1], hit[defect+mask.. strip+group_size-1]
61 // iter++ < strip-mask+1
62 // C) n defects overlapping
63 // => lower_bound(strip+group_size()-1) < strip >= strip-mask+1 -> hit[defect+mask.. strip+group_size-1],
64 // defect+mast>strip ? hit[defect+mask.. last_defect-1] -> loop
65 // : hit[strip..last_defect-1] -> end
66
67 StripModuleHelper::KEY_TYPE rdo_key = module_helper.hardwareCoordinates(row_idx_aka_phi, col_idx_aka_eta);
68 unsigned int strip = module_helper.getRow(rdo_key);
69 std::pair<unsigned int, unsigned int> overlap = (defect_iter != end_iter
70 ? getOverlap( module_helper,
72 strip,
73 rdo.getGroupSize())
74 : std::make_pair(0u,0u));
75 if (overlap.second==0) {
76 dest.push_back(std::make_unique<SCT3_RawData>(dynamic_cast<const SCT3_RawData &>(rdo)).release() );
77 ++n_new;
78 }
79 else if (static_cast<unsigned int>(rdo.getGroupSize()) != overlap.second) {
80 const SCT3_RawData &sct3_rdo = dynamic_cast<const SCT3_RawData &>(rdo);
81 Identifier module_id = m_idHelper->module_id(rdo.identify());
82
83 unsigned int last_defect_start = strip + rdo.getGroupSize();
84 for (;;) {
85 unsigned int start = overlap.first + overlap.second;
86 unsigned int group_size = last_defect_start - start;
87 if (group_size > 0) {
88 dest.push_back(std::make_unique<SCT3_RawData>( m_idHelper->strip_id(module_id,start, col_idx_aka_eta),
89 makeStripWord( sct3_rdo.getTimeBin(), start, group_size, getErrorBits(rdo) ),
91 ++n_new;
92 }
93 if (overlap.first == strip) break;
94 last_defect_start = overlap.first;
95
96 // if it is a range the range end key is already handled
97 // so skip it.
98 ++defect_iter;
99 if (defect_iter != end_iter && StripModuleHelper::isRangeKey(*defect_iter)) {
100 // make sure that last_defect start is not smaller than the first strip in the strip group
101 // otherwise the group size for the next strip group would become negative.
102 last_defect_start = std::max(static_cast<unsigned int>(module_helper.getRow(*defect_iter)),strip);
103 ++defect_iter;
104 }
105
106 if (defect_iter != end_iter) {
107 overlap = getOverlap( module_helper,
109 strip,
110 rdo.getGroupSize());
111 }
112 else {
113 overlap.first=strip;
114 overlap.second=0u;
115 }
116 }
117 }
118 return n_new;
119 }
120
121 protected:
129 static inline unsigned int makeStripWord( unsigned int time_bin, unsigned int strip, unsigned int group_size, unsigned int error_bits) {
130 assert((group_size & (~0x7FFu)) == 0u);
131 assert((strip & (~0x7FFu)) == 0u);
132 assert((time_bin & (~0x7u)) == 0u);
133 assert((error_bits & (~0x3Fu)) == 0u );
134 unsigned int word = group_size | (strip<<11u) | (time_bin<<22u) | (error_bits <<25u);
135 return word;
136 }
137
139 static inline unsigned int getErrorBits( const SCT_RDORawData &rdo ) {
140 return (rdo.getWord() >>25u) & 0x7u;
141 }
142
150 std::pair<unsigned int,unsigned int> getOverlap( const StripModuleHelper &module_helper,
151 const std::pair<StripModuleHelper::KEY_TYPE, StripModuleHelper::KEY_TYPE> &defect_range,
152 unsigned int strip,
153 unsigned int sequence_length) {
156 unsigned int defect_row_start = module_helper.getRow(defect_range.first);
157 unsigned int defect_row_end = module_helper.getRow(defect_range.second)+1;
158 unsigned int strip_row = strip;
159 if (defect_row_end-defect_row_start>1u) {
160 if (defect_row_end >= strip_row && defect_row_start < strip_row+sequence_length) {
161 unsigned int overlap_start = defect_row_start > strip_row ? defect_row_start : strip_row;
162 unsigned int overlap_end = defect_row_end < strip_row+sequence_length ? defect_row_end : strip_row+sequence_length;
163 return std::make_pair( overlap_start , overlap_end- overlap_start);
164 }
165 }
166 else {
167 if (defect_row_start >= strip_row && defect_row_start < strip_row+sequence_length) {
168 return std::make_pair(defect_row_start,1u);
169 }
170 }
171 return std::make_pair(strip,0u);
172 }
173
174
175 };
176
182 };
183
191 class StripDefectsEmulatorAlg :public DefectsEmulatorAlg<SCT_RDO_Container>
192 {
193 public:
195 };
196}
197#endif
This is an Identifier helper class for the SCT subdetector.
InDetRawDataContainer< InDetRawDataCollection< SCT_RDORawData > > SCT_RDO_Container
Base class for the SCT module side design, extended by the Forward and Barrel module design.
virtual Identifier identify() const override final
unsigned int getWord() const
Algorithm template to selectivly copy RDOs from an InDetRawDataCollection.
static std::pair< typename std::vector< KEY_TYPE >::iterator, typename std::vector< KEY_TYPE >::iterator > lower_bound(std::vector< KEY_TYPE > &module_defects, KEY_TYPE key)
Convenience method to find the preceding defect.
static std::pair< KEY_TYPE, KEY_TYPE > getRange(typename std::vector< KEY_TYPE >::const_iterator key_iter)
Convenience method to get a range of keys.
Algorithm which selectively copies hits from an input SCT_RDO_Container.
Specialization of emulated defects conditions data for ITk strips Defect conditions data for defects ...
Helper class to convert between offline column, row and hardware chip, column, row coordinates.
KEY_TYPE hardwareCoordinates(unsigned int row, unsigned int column) const
Compute "hardware" coordinates from offline coordinates.
int getTimeBin() const
This is an Identifier helper class for the SCT subdetector.
Definition SCT_ID.h:68
virtual int getGroupSize() const =0
static std::string release
Definition computils.h:50
DetectorType
Simple enum to Identify the Type of the ACTS sub detector.
Primary Vertex Finder.
std::unique_ptr< SCT3_RawData > createNoiseHit(const T_ModuleHelper &helper, const Identifier &identifier, unsigned int cell_idx, unsigned int tot)
static unsigned int getErrorBits(const SCT_RDORawData &rdo)
Convenience method to extract the error component from the packed word of the strip RDO.
std::pair< unsigned int, unsigned int > getOverlap(const StripModuleHelper &module_helper, const std::pair< StripModuleHelper::KEY_TYPE, StripModuleHelper::KEY_TYPE > &defect_range, unsigned int strip, unsigned int sequence_length)
Convenience function to return the defect region overlapping with the strip group.
static unsigned int makeStripWord(unsigned int time_bin, unsigned int strip, unsigned int group_size, unsigned int error_bits)
Convenience method to create the strip word from the various components.
unsigned int cloneOrRejectHit(const StripModuleHelper &module_helper, const StripEmulatedDefects &emulated_defects, unsigned int idHash, unsigned int row_idx_aka_phi, unsigned int col_idx_aka_eta, const SCT_RDORawData &rdo, InDetRawDataCollection< SCT_RDORawData > &dest)
Clone, reject or split strip RDOs depending on overlaps with defects.
static constexpr ActsTrk::DetectorType DETECTOR_TYPE
static constexpr T getRow(T key)
Get the row index from a full key.
static constexpr bool isRangeKey(unsigned short key)