ATLAS Offline Software
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 
13 namespace Muon {
14  using namespace MuonStationIndex;
15  MuonLayerHashProviderTool::MuonLayerHashProviderTool(const std::string& type, const std::string& name, const IInterface* parent):
17  declareInterface<MuonLayerHashProviderTool>(this);
18 
19  }
20 
22 
23  ATH_CHECK(m_idHelperSvc.retrieve());
25 
26  if( !initializeSectorMapping() ){
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
49  MuonIdHelper::const_id_iterator it_end = idHelper.module_end();
50  for( ;it!=it_end; ++it ){
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 }
xAOD::iterator
JetConstituentVector::iterator iterator
Definition: JetConstituentVector.cxx:68
Muon::MuonLayerHashProviderTool::MuonLayerHashProviderTool
MuonLayerHashProviderTool(const std::string &type, const std::string &name, const IInterface *parent)
Default AlgTool functions.
Definition: MuonLayerHashProviderTool.cxx:15
Muon::MuonLayerHashProviderTool::insertTgcs
void insertTgcs() const
insert hashes for the tgcs
Definition: MuonLayerHashProviderTool.cxx:58
Muon::MuonLayerHashProviderTool::m_tgcHash
std::mutex m_tgcHash
Definition: MuonLayerHashProviderTool.h:77
SG::ReadCondHandle
Definition: ReadCondHandle.h:44
Muon::MuonStationIndex::sectorLayerHashMax
constexpr unsigned int sectorLayerHashMax()
maximum create a hash out of region and layer
Definition: MuonStationIndex.h:110
Muon::MuonSectorMapping::getSectors
void getSectors(double phi, std::vector< int > &sectors) const
returns the main sector plus neighboring if the phi position is in an overlap region
Definition: MuonSectorMapping.h:97
Muon::MuonStationIndex::sectorLayerHash
unsigned int sectorLayerHash(DetectorRegionIndex detectorRegionIndex, LayerIndex layerIndex)
create a hash out of region and layer
TRTCalib_cfilter.p1
p1
Definition: TRTCalib_cfilter.py:130
skel.it
it
Definition: skel.GENtoEVGEN.py:407
MuonIdHelper::module_end
const_id_iterator module_end() const
Definition: MuonIdHelper.cxx:760
Muon::MuonLayerHashProviderTool::insertTechnology
void insertTechnology(const MuonIdHelper &idHelper)
insert hashes of a given technology
Definition: MuonLayerHashProviderTool.cxx:45
Muon
NRpcCablingAlg reads raw condition data and writes derived condition data to the condition store.
Definition: TrackSystemController.h:45
python.CaloAddPedShiftConfig.type
type
Definition: CaloAddPedShiftConfig.py:42
Muon::MuonStationIndex::numberOfSectors
constexpr unsigned numberOfSectors()
return total number of sectors
Definition: MuonStationIndex.h:118
MuonGM::TgcReadoutElement::channelPos
Amg::Vector3D channelPos(const Identifier &id) const
Returns the position of the active channel (wireGang or strip)
TRTCalib_cfilter.p2
p2
Definition: TRTCalib_cfilter.py:131
Muon::MuonLayerHashProviderTool::insertHash
void insertHash(const IdentifierHash &hash, const Identifier &id) const
insert a single hash for a given identifier
Definition: MuonLayerHashProviderTool.cxx:35
Muon::MuonLayerHashProviderTool::m_idHelperSvc
ServiceHandle< Muon::IMuonIdHelperSvc > m_idHelperSvc
Definition: MuonLayerHashProviderTool.h:79
MuonIdHelper
Definition: MuonIdHelper.h:80
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
Muon::MuonLayerHashProviderTool::initialize
StatusCode initialize() override
Definition: MuonLayerHashProviderTool.cxx:21
lumiFormat.i
int i
Definition: lumiFormat.py:85
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
MuonIdHelper::get_module_hash
virtual int get_module_hash(const Identifier &id, IdentifierHash &hash_id) const
Definition: MuonIdHelper.cxx:99
MuonGM::TgcReadoutElement
A TgcReadoutElement corresponds to a single TGC chamber; therefore typically a TGC station contains s...
Definition: MuonDetDescr/MuonReadoutGeometry/MuonReadoutGeometry/TgcReadoutElement.h:42
test_pyathena.parent
parent
Definition: test_pyathena.py:15
Muon::MuonLayerHashProviderTool::initializeSectorMapping
bool initializeSectorMapping()
initialize the mapping structure
Definition: MuonLayerHashProviderTool.cxx:103
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
MuonGM::TgcReadoutElement::nStrips
int nStrips(int gasGap) const
Returns the number of strips in a given gas gap.
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:240
MuonR4::SegmentFit::toInt
constexpr int toInt(const ParamDefs p)
Definition: MuonHoughDefs.h:42
SG::CondHandleKey::initialize
StatusCode initialize(bool used=true)
Amg::Vector3D
Eigen::Matrix< double, 3, 1 > Vector3D
Definition: GeoPrimitives.h:47
MuonDetectorManager.h
MuonLayerHashProviderTool.h
MuonSectorMapping.h
CaloCondBlobAlgs_fillNoiseFromASCII.hash
dictionary hash
Definition: CaloCondBlobAlgs_fillNoiseFromASCII.py:108
MuonIdHelper::const_id_iterator
std::vector< Identifier >::const_iterator const_id_iterator
Definition: MuonIdHelper.h:143
Muon::MuonSectorMapping
Definition: MuonSectorMapping.h:20
TgcReadoutElement.h
AthAlgTool
Definition: AthAlgTool.h:26
Muon::MuonLayerHashProviderTool::m_detMgrKey
SG::ReadCondHandleKey< MuonGM::MuonDetectorManager > m_detMgrKey
Definition: MuonLayerHashProviderTool.h:81
MuonIdHelper::module_begin
const_id_iterator module_begin() const
Iterators over full set of ids.
Definition: MuonIdHelper.cxx:758
IdentifierHash
This is a "hash" representation of an Identifier. This encodes a 32 bit index which can be used to lo...
Definition: IdentifierHash.h:25
Identifier
Definition: IdentifierFieldParser.cxx:14