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(); // ->strip
34 unsigned int col_aka_eta=cell_idx / helper.rows(); // ->sensor row i.e. 1
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,col_aka_eta, row_aka_phi),
38 makeStripWord( /*time bin */ tot, /*stripIn11bits*/ row_aka_phi, group_size, errors ),
40 }
41 unsigned int nConsecutiveRows(const SCT_RDORawData &rdo) const {
42 return rdo.getGroupSize();
43 }
44
47 unsigned int cloneOrRejectHit( const StripModuleHelper &module_helper,
48 const StripEmulatedDefects &emulated_defects,
49 unsigned int idHash,
50 unsigned int row_idx_aka_phi,
51 unsigned int col_idx_aka_eta,
52 const SCT_RDORawData &rdo,
54 unsigned int n_new=0u;
55 assert( rdo.getGroupSize() > 0);
56 // search for all defects starting from the last strip in the group (search is performed in descending order)
57 StripModuleHelper::KEY_TYPE rdo_end_key = module_helper.hardwareCoordinates(row_idx_aka_phi+rdo.getGroupSize()-1, col_idx_aka_eta);
58 auto [defect_iter, end_iter] =emulated_defects.lower_bound(idHash, rdo_end_key);
59
60 // A) 0 defect overlapping with strip group
61 // => lower_bound(strip+group_size()-1) < strip-mask+1 -> clone
62 // B) 1 defect overlapping
63 // => lower_bound(strip+group_size()-1) < strip >= strip-mask+1 -> hit[strip .. defect-1], hit[defect+mask.. strip+group_size-1]
64 // iter++ < strip-mask+1
65 // C) n defects overlapping
66 // => lower_bound(strip+group_size()-1) < strip >= strip-mask+1 -> hit[defect+mask.. strip+group_size-1],
67 // defect+mast>strip ? hit[defect+mask.. last_defect-1] -> loop
68 // : hit[strip..last_defect-1] -> end
69
70 StripModuleHelper::KEY_TYPE rdo_key = module_helper.hardwareCoordinates(row_idx_aka_phi, col_idx_aka_eta);
71 unsigned int strip = module_helper.getRow(rdo_key);
72 std::pair<unsigned int, unsigned int> overlap = (defect_iter != end_iter
73 ? getOverlap( module_helper,
75 strip,
76 rdo.getGroupSize())
77 : std::make_pair(0u,0u));
78 if (overlap.second==0) {
79 dest.push_back(std::make_unique<SCT3_RawData>(dynamic_cast<const SCT3_RawData &>(rdo)).release() );
80 ++n_new;
81 }
82 else if (static_cast<unsigned int>(rdo.getGroupSize()) != overlap.second) {
83 const SCT3_RawData &sct3_rdo = dynamic_cast<const SCT3_RawData &>(rdo);
84 Identifier module_id = m_idHelper->module_id(rdo.identify());
85
86 unsigned int last_defect_start = strip + rdo.getGroupSize();
87 for (;;) {
88 unsigned int start = overlap.first + overlap.second;
89 unsigned int group_size = last_defect_start - start;
90 if (group_size > 0) {
91 dest.push_back(std::make_unique<SCT3_RawData>( m_idHelper->strip_id(module_id,col_idx_aka_eta, start),
92 makeStripWord( sct3_rdo.getTimeBin(), start, group_size, getErrorBits(rdo) ),
94 ++n_new;
95 }
96 if (overlap.first == strip) break;
97 last_defect_start = overlap.first;
98
99 // if it is a range the range end key is already handled
100 // so skip it.
101 ++defect_iter;
102 if (defect_iter != end_iter && StripModuleHelper::isRangeKey(*defect_iter)) {
103 // make sure that last_defect start is not smaller than the first strip in the strip group
104 // otherwise the group size for the next strip group would become negative.
105 last_defect_start = std::max(static_cast<unsigned int>(module_helper.getRow(*defect_iter)),strip);
106 ++defect_iter;
107 }
108
109 if (defect_iter != end_iter) {
110 overlap = getOverlap( module_helper,
112 strip,
113 rdo.getGroupSize());
114 }
115 else {
116 overlap.first=strip;
117 overlap.second=0u;
118 }
119 }
120 }
121 return n_new;
122 }
123
124 protected:
132 static inline unsigned int makeStripWord( unsigned int time_bin, unsigned int strip, unsigned int group_size, unsigned int error_bits) {
133 assert((group_size & (~0x7FFu)) == 0u);
134 assert((strip & (~0x7FFu)) == 0u);
135 assert((time_bin & (~0x7u)) == 0u);
136 assert((error_bits & (~0x3Fu)) == 0u );
137 unsigned int word = group_size | (strip<<11u) | (time_bin<<22u) | (error_bits <<25u);
138 return word;
139 }
140
142 static inline unsigned int getErrorBits( const SCT_RDORawData &rdo ) {
143 return (rdo.getWord() >>25u) & 0x7u;
144 }
145
153 std::pair<unsigned int,unsigned int> getOverlap( const StripModuleHelper &module_helper,
154 const std::pair<StripModuleHelper::KEY_TYPE, StripModuleHelper::KEY_TYPE> &defect_range,
155 unsigned int strip,
156 unsigned int sequence_length) {
159 unsigned int defect_row_start = module_helper.getRow(defect_range.first);
160 unsigned int defect_row_end = module_helper.getRow(defect_range.second)+1;
161 unsigned int strip_row = strip;
162 if (defect_row_end-defect_row_start>1u) {
163 if (defect_row_end >= strip_row && defect_row_start < strip_row+sequence_length) {
164 unsigned int overlap_start = defect_row_start > strip_row ? defect_row_start : strip_row;
165 unsigned int overlap_end = defect_row_end < strip_row+sequence_length ? defect_row_end : strip_row+sequence_length;
166 return std::make_pair( overlap_start , overlap_end- overlap_start);
167 }
168 }
169 else {
170 if (defect_row_start >= strip_row && defect_row_start < strip_row+sequence_length) {
171 return std::make_pair(defect_row_start,1u);
172 }
173 }
174 return std::make_pair(strip,0u);
175 }
176
177
178 };
179
185 };
186
194 class StripDefectsEmulatorAlg :public DefectsEmulatorAlg<SCT_RDO_Container>
195 {
196 public:
198 };
199}
200#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.
unsigned int nConsecutiveRows(const SCT_RDORawData &rdo) const
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)