ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
InnerDetector
InDetValidation
InDetDefectsEmulation
src
ConnectedModulesUtil.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 CONNECTEDMODULESUTIL_H
5
#define CONNECTEDMODULESUTIL_H
6
7
#include "
InDetReadoutGeometry/SiDetectorElement.h
"
8
#include "
InDetReadoutGeometry/SiDetectorElementCollection.h
"
9
10
#include <vector>
11
#include <ranges>
12
#include <unordered_map>
13
#include <functional>
14
15
#include "
ModuleIdentifierMatchUtil.h
"
16
namespace
InDet
{
17
namespace
ConnectedModulesUtil
{
18
26
template
<
class
T_ID>
27
std::unordered_multimap<unsigned int, unsigned int>
28
inline
createModuleConnectionMap
(
const
T_ID &id_helper,
29
const
InDetDD::SiDetectorElementCollection
&det_ele_coll) {
30
std::unordered_multimap<unsigned int, unsigned int> connected_modules;
31
std::size_t det_ele_coll_sz = det_ele_coll.
size
();
32
for
(
unsigned
int
module_i=0u;module_i<det_ele_coll_sz;++module_i) {
33
const
InDetDD::SiDetectorElement
*det_ele = det_ele_coll[module_i];
34
const
InDetDD::SiDetectorElement
*side_det_ele = det_ele;
35
for
(
unsigned
int
side_i=0; side_i<2; ++side_i) {
36
const
GeoVFullPhysVol*phys_vol = side_det_ele->getMaterialGeom();
37
if
(phys_vol) {
38
connected_modules.insert( std::make_pair(phys_vol->getId(), module_i));
39
}
40
unsigned
int
id_hash = id_helper.get_other_side(det_ele->
identifyHash
());
41
if
(id_hash >= det_ele_coll.
size
())
break
;
42
side_det_ele = det_ele_coll[id_hash];
43
}
44
}
45
return
connected_modules;
46
}
47
59
template
<
class
T_ID>
60
inline
void
visitMatchingConnectedModules
(
const
T_ID &id_helper,
61
const
std::vector<int> &a_module_pattern,
62
const
InDetDD::SiDetectorElementCollection
&det_ele_coll,
63
unsigned
id_hash,
64
const
std::unordered_multimap<unsigned int, unsigned int> &connected_modules,
65
std::function<
void
(
unsigned
int
id_hash,
const
InDetDD::SiDetectorElement
&)> visit_func) {
66
assert( id_hash < det_ele_coll.
size
() );
67
if
(
ModuleIdentifierMatchUtil::matchesAllModuleRowsOfSensor
(a_module_pattern)
68
||
ModuleIdentifierMatchUtil::matchesBothSides
(a_module_pattern)) {
69
const
InDetDD::SiDetectorElement
*det_ele = det_ele_coll[id_hash];
70
// propagate the defect to all modules connected to the same physical sensor
71
// i.e. also mark opposite side or other rows as defect if configured accordingly
72
if
(det_ele->getMaterialGeom()) {
73
std::pair< std::unordered_multimap< unsigned int, unsigned int>::const_iterator,
74
std::unordered_multimap< unsigned int, unsigned int>::const_iterator >
75
childs = connected_modules.equal_range(det_ele->getMaterialGeom()->getId());
76
unsigned
int
other_side_id_hash = id_helper.get_other_side(det_ele->
identifyHash
());
77
using
ConnectedKey_t =
unsigned
int;
78
for
(
const
std::pair<const ConnectedKey_t, unsigned int> &child : std::ranges::subrange(childs.first, childs.second)) {
79
assert( child.second < det_ele_coll.
size
());
80
const
InDetDD::SiDetectorElement
*connected_det_ele( det_ele_coll[child.second] );
81
int
side = id_helper.side( connected_det_ele->
identify
());
82
if
(
ModuleIdentifierMatchUtil::isSideMatching
(a_module_pattern, side)
83
&& (
ModuleIdentifierMatchUtil::matchesAllModuleRowsOfSensor
(a_module_pattern)
84
|| child.second == other_side_id_hash)) {
85
assert(connected_det_ele);
86
visit_func(child.second, *connected_det_ele);
87
}
88
}
89
}
90
}
91
}
92
93
}
94
}
95
#endif
ModuleIdentifierMatchUtil.h
SiDetectorElementCollection.h
SiDetectorElement.h
DataVector::size
size_type size() const noexcept
Returns the number of elements in the collection.
InDetDD::SiDetectorElementCollection
Class to hold the SiDetectorElement objects to be put in the detector store.
Definition
SiDetectorElementCollection.h:27
InDetDD::SiDetectorElement
Class to hold geometrical description of a silicon detector element.
Definition
SiDetectorElement.h:109
InDetDD::SolidStateDetectorElementBase::identifyHash
virtual IdentifierHash identifyHash() const override final
identifier hash (inline)
InDetDD::SolidStateDetectorElementBase::identify
virtual Identifier identify() const override final
identifier of this detector element (inline)
InDet::ConnectedModulesUtil
Definition
ConnectedModulesUtil.h:17
InDet::ConnectedModulesUtil::visitMatchingConnectedModules
void visitMatchingConnectedModules(const T_ID &id_helper, const std::vector< int > &a_module_pattern, const InDetDD::SiDetectorElementCollection &det_ele_coll, unsigned id_hash, const std::unordered_multimap< unsigned int, unsigned int > &connected_modules, std::function< void(unsigned int id_hash, const InDetDD::SiDetectorElement &)> visit_func)
Visit all detector elements connected to the same physical sensor which match the given pattern.
Definition
ConnectedModulesUtil.h:60
InDet::ConnectedModulesUtil::createModuleConnectionMap
std::unordered_multimap< unsigned int, unsigned int > createModuleConnectionMap(const T_ID &id_helper, const InDetDD::SiDetectorElementCollection &det_ele_coll)
create a map between detector elements and all such elements connected the same sensor
Definition
ConnectedModulesUtil.h:28
InDet::ModuleIdentifierMatchUtil::matchesAllModuleRowsOfSensor
bool matchesAllModuleRowsOfSensor(const std::vector< int > &a_module_pattern)
Test whether a pattern matches all module rows of a sensor or just a single row.
Definition
ModuleIdentifierMatchUtil.h:206
InDet::ModuleIdentifierMatchUtil::matchesBothSides
bool matchesBothSides(const std::vector< int > &a_module_pattern)
Test whether the given pattern matches identifiers which refer to either side of a sensor.
Definition
ModuleIdentifierMatchUtil.h:186
InDet::ModuleIdentifierMatchUtil::isSideMatching
bool isSideMatching(const std::vector< int > &a_module_pattern, int side)
Test whether the given pattern matches the given side.
Definition
ModuleIdentifierMatchUtil.h:193
InDet
Primary Vertex Finder.
Definition
VP1ErrorUtils.h:36
Generated on
for ATLAS Offline Software by
1.17.0