4#ifndef CONNECTEDMODULESUTIL_H
5#define CONNECTEDMODULESUTIL_H
12#include <unordered_map>
27 std::unordered_multimap<unsigned int, unsigned int>
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) {
35 for (
unsigned int side_i=0; side_i<2; ++side_i) {
36 const GeoVFullPhysVol*phys_vol = side_det_ele->getMaterialGeom();
38 connected_modules.insert( std::make_pair(phys_vol->getId(), module_i));
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];
45 return connected_modules;
61 const std::vector<int> &a_module_pattern,
64 const std::unordered_multimap<unsigned int, unsigned int> &connected_modules,
66 assert( id_hash < det_ele_coll.
size() );
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());
81 int side = id_helper.side( connected_det_ele->
identify());
84 || child.second == other_side_id_hash)) {
85 assert(connected_det_ele);
86 visit_func(child.second, *connected_det_ele);
size_type size() const noexcept
Returns the number of elements in the collection.
Class to hold the SiDetectorElement objects to be put in the detector store.
Class to hold geometrical description of a silicon detector element.
virtual IdentifierHash identifyHash() const override final
identifier hash (inline)
virtual Identifier identify() const override final
identifier of this detector element (inline)
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.
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
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.
bool matchesBothSides(const std::vector< int > &a_module_pattern)
Test whether the given pattern matches identifiers which refer to either side of a sensor.
bool isSideMatching(const std::vector< int > &a_module_pattern, int side)
Test whether the given pattern matches the given side.