ATLAS Offline Software
Loading...
Searching...
No Matches
MuonLayerHashProviderTool.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3*/
4
6
7
10
12
13namespace Muon {
14 using namespace MuonStationIndex;
15 MuonLayerHashProviderTool::MuonLayerHashProviderTool(const std::string& type, const std::string& name, const IInterface* parent):
16 AthAlgTool(type,name,parent) {
17 declareInterface<MuonLayerHashProviderTool>(this);
18
19 }
20
22
23 ATH_CHECK(m_idHelperSvc.retrieve());
24 ATH_CHECK(m_detMgrKey.initialize());
25
27 ATH_MSG_ERROR("Failed to initialize sector mapping");
28 return StatusCode::FAILURE;
29 }
30
31 return StatusCode::SUCCESS;
32 }
33
34
36 insertHash(m_idHelperSvc->sector(id),hash,id);
37 }
38
39 void MuonLayerHashProviderTool::insertHash( int sector, const IdentifierHash& hash, const Identifier& id ) const {
40 const int techIndex = toInt(m_idHelperSvc->technologyIndex(id));
41 const int layHash = sectorLayerHash(m_idHelperSvc->regionIndex(id),m_idHelperSvc->layerIndex(id));
42 m_regionHashesPerSector[sector-1].technologyRegionHashVecs[techIndex][layHash].push_back(hash);
43 }
44
46
47 // loop over all available STGC collection identifiers and order them per sector
50 for( ;it!=it_end; ++it ){
51 IdentifierHash hash;
52 idHelper.get_module_hash(*it,hash);
53 insertHash(hash,*it);
54 }
55
56 }
57
59 std::lock_guard guard{m_tgcHash};
60 if (m_hashLoaded) return;
61 // the tgc's can be in multiple sectors so we need to do something special here
63
64 MuonSectorMapping sectorMapping;
65
66 // loop over all available TGC collection identifiers and order them per sector
67 MuonIdHelper::const_id_iterator it = m_idHelperSvc->tgcIdHelper().module_begin();
68 MuonIdHelper::const_id_iterator it_end = m_idHelperSvc->tgcIdHelper().module_end();
69 for( ;it!=it_end; ++it ){
70 const MuonGM::TgcReadoutElement* detEl = detMgr->getTgcReadoutElement(*it);
71 if( !detEl ) {
72 ATH_MSG_DEBUG(" No detector element found for " << m_idHelperSvc->toString(*it) );
73 continue;
74 }
75 const IdentifierHash hash = m_idHelperSvc->moduleHash(*it);
76 int nstrips = detEl->nStrips(1);
77 Amg::Vector3D p1 = detEl->channelPos(1,1,1);
78 Amg::Vector3D p2 = detEl->channelPos(1,1,nstrips);
79 std::vector<int> sectors1;
80 sectorMapping.getSectors(p1.phi(),sectors1);
81 std::set<int> added;
82 std::vector<int>::iterator sit = sectors1.begin();
83 std::vector<int>::iterator sit_end = sectors1.end();
84 for( ;sit!=sit_end; ++sit ){
85 insertHash(*sit,hash,*it);
86 added.insert(*sit);
87 }
88
89 std::vector<int> sectors2;
90 sectorMapping.getSectors(p2.phi(),sectors2);
91 sit = sectors2.begin();
92 sit_end = sectors2.end();
93 for( ;sit!=sit_end; ++sit ){
94 if( added.count(*sit) ) continue;
95 added.insert(*sit);
96 insertHash(*sit,hash,*it);
97 }
98 }
99 m_hashLoaded = true;
100 }
101
102 // all chambers are mapped onto a layer and sector map
104 // set sector numbers
105 for( unsigned int i=0;i<m_regionHashesPerSector.size();++i ) {
106 m_regionHashesPerSector[i].sector=i+1;
107 }
108 ATH_MSG_DEBUG("Initializing hashes: number of sectors " << numberOfSectors()
109 << " sectorLayers " << sectorLayerHashMax() );
110
111 // add technologies
112 if (m_idHelperSvc->hasMDT()) insertTechnology(m_idHelperSvc->mdtIdHelper());
113 if (m_idHelperSvc->hasRPC()) insertTechnology(m_idHelperSvc->rpcIdHelper());
114 if (m_idHelperSvc->hasCSC()) insertTechnology(m_idHelperSvc->cscIdHelper());
115 if (m_idHelperSvc->hasMM()) insertTechnology(m_idHelperSvc->mmIdHelper());
116 if (m_idHelperSvc->hasSTGC()) insertTechnology(m_idHelperSvc->stgcIdHelper());
117 return true;
118 }
119
120}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_ERROR(x)
#define ATH_MSG_DEBUG(x)
AthAlgTool(const std::string &type, const std::string &name, const IInterface *parent)
Constructor with parameters:
This is a "hash" representation of an Identifier.
A TgcReadoutElement corresponds to a single TGC chamber; therefore typically a TGC station contains s...
Amg::Vector3D channelPos(const Identifier &id) const
Returns the position of the active channel (wireGang or strip)
int nStrips(int gasGap) const
Returns the number of strips in a given gas gap.
std::vector< Identifier >::const_iterator const_id_iterator
const_id_iterator module_end() const
const_id_iterator module_begin() const
Iterators over full set of ids.
virtual int get_module_hash(const Identifier &id, IdentifierHash &hash_id) const
SG::ReadCondHandleKey< MuonGM::MuonDetectorManager > m_detMgrKey
MuonLayerHashProviderTool(const std::string &type, const std::string &name, const IInterface *parent)
Default AlgTool functions.
void insertHash(const IdentifierHash &hash, const Identifier &id) const
insert a single hash for a given identifier
void insertTgcs() const
insert hashes for the tgcs
void insertTechnology(const MuonIdHelper &idHelper)
insert hashes of a given technology
bool initializeSectorMapping()
initialize the mapping structure
ServiceHandle< Muon::IMuonIdHelperSvc > m_idHelperSvc
void getSectors(double phi, std::vector< int > &sectors) const
returns the main sector plus neighboring if the phi position is in an overlap region
Eigen::Matrix< double, 3, 1 > Vector3D
constexpr unsigned numberOfSectors()
return total number of sectors
constexpr int toInt(const EnumType enumVal)
constexpr unsigned int sectorLayerHashMax()
maximum create a hash out of region and layer
unsigned int sectorLayerHash(DetectorRegionIndex detectorRegionIndex, LayerIndex layerIndex)
create a hash out of region and layer
NRpcCablingAlg reads raw condition data and writes derived condition data to the condition store.