ATLAS Offline Software
MuonLayerHashProviderTool.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 #ifndef MUON_MUONLAYERHASHPROVIDERTOOL_H
6 #define MUON_MUONLAYERHASHPROVIDERTOOL_H
7 
9 
13 
14 #include <mutex>
15 #include <string>
16 #include <vector>
17 #include <array>
18 
19 
20 namespace Muon {
21 
23  public:
29  using HashVec = std::vector<IdentifierHash>;
30 
33  static constexpr unsigned techMax = MuonStationIndex::toInt(TechnologyIndex::TechnologyIndexMax);
34  using TechnologyRegionHashVec = std::array< RegionHashVec, techMax>;
35 
37  int sector{-1};
39  };
41 
43  const HashVec& getHashes( int sector, TechnologyIndex technologyIndex, unsigned int sectorLayerHash ) const;
44 
46  MuonLayerHashProviderTool(const std::string& type, const std::string& name, const IInterface* parent);
47  virtual ~MuonLayerHashProviderTool()=default;
48  StatusCode initialize() override;
49 
51  static const InterfaceID& interfaceID() {
52  static const InterfaceID IID_MuonLayerHashProviderTool("Muon::MuonLayerHashProviderTool",1,0);
53  return IID_MuonLayerHashProviderTool;
54  }
55 
56 
57  private:
58 
60  void insertTechnology( const MuonIdHelper& idHelper );
61 
63  void insertTgcs() const;
64 
66  void insertHash( const IdentifierHash& hash, const Identifier& id ) const;
67 
69  void insertHash( int sector, const IdentifierHash& hash, const Identifier& id ) const;
70 
73 
75  mutable RegionHashesPerSectorVec m_regionHashesPerSector ATLAS_THREAD_SAFE{};
76  mutable std::atomic<bool> m_hashLoaded ATLAS_THREAD_SAFE{false};
77  mutable std::mutex m_tgcHash{};
78 
79  ServiceHandle<Muon::IMuonIdHelperSvc> m_idHelperSvc {this, "MuonIdHelperSvc", "Muon::MuonIdHelperSvc/MuonIdHelperSvc"};
80 
81  SG::ReadCondHandleKey<MuonGM::MuonDetectorManager> m_detMgrKey{this, "DetMgr", "MuonDetectorManager",
82  "MuonManager ReadKey for IOV Range intersection"};
83 
84 
85  };
86 
87 
88  inline const std::vector<IdentifierHash>& MuonLayerHashProviderTool::getHashes( int sector, TechnologyIndex technologyIndex,
89  unsigned int sectorLayerHash ) const {
90  if (!m_hashLoaded){
91  insertTgcs();
92  }
93  using namespace MuonStationIndex;
94  return m_regionHashesPerSector[sector-1].technologyRegionHashVecs[toInt(technologyIndex)][sectorLayerHash];
95  }
96 }
97 
98 
99 
100 #endif
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::HashVec
std::vector< IdentifierHash > HashVec
define data structure
Definition: MuonLayerHashProviderTool.h:29
Muon::MuonLayerHashProviderTool::m_tgcHash
std::mutex m_tgcHash
Definition: MuonLayerHashProviderTool.h:77
Muon::MuonLayerHashProviderTool
Definition: MuonLayerHashProviderTool.h:22
Muon::MuonStationIndex::sectorLayerHashMax
constexpr unsigned int sectorLayerHashMax()
maximum create a hash out of region and layer
Definition: MuonStationIndex.h:110
BeamSpot::mutex
std::mutex mutex
Definition: InDetBeamSpotVertex.cxx:18
Muon::MuonStationIndex::sectorLayerHash
unsigned int sectorLayerHash(DetectorRegionIndex detectorRegionIndex, LayerIndex layerIndex)
create a hash out of region and layer
Muon::MuonStationIndex::TechnologyIndex
TechnologyIndex
enum to classify the different layers in the muon spectrometer
Definition: MuonStationIndex.h:54
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
Muon::MuonLayerHashProviderTool::RegionHashesPerSector
Definition: MuonLayerHashProviderTool.h:36
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
Muon::MuonLayerHashProviderTool::TechnologyRegionHashVec
std::array< RegionHashVec, techMax > TechnologyRegionHashVec
Definition: MuonLayerHashProviderTool.h:34
MuonIdHelper
Definition: MuonIdHelper.h:80
Muon::MuonLayerHashProviderTool::initialize
StatusCode initialize() override
Definition: MuonLayerHashProviderTool.cxx:21
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
Muon::MuonLayerHashProviderTool::RegionHashesPerSector::sector
int sector
Definition: MuonLayerHashProviderTool.h:37
AthAlgTool.h
test_pyathena.parent
parent
Definition: test_pyathena.py:15
Muon::MuonLayerHashProviderTool::initializeSectorMapping
bool initializeSectorMapping()
initialize the mapping structure
Definition: MuonLayerHashProviderTool.cxx:103
Muon::MuonLayerHashProviderTool::getHashes
const HashVec & getHashes(int sector, TechnologyIndex technologyIndex, unsigned int sectorLayerHash) const
access hashes for a given sector, technology and layer hash
Definition: MuonLayerHashProviderTool.h:88
ReadCondHandleKey.h
lumiFormat.array
array
Definition: lumiFormat.py:91
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:240
MuonDetectorManager.h
Muon::MuonLayerHashProviderTool::RegionHashesPerSectorVec
std::array< RegionHashesPerSector, MuonStationIndex::numberOfSectors()> RegionHashesPerSectorVec
Definition: MuonLayerHashProviderTool.h:40
Muon::MuonLayerHashProviderTool::~MuonLayerHashProviderTool
virtual ~MuonLayerHashProviderTool()=default
SG::ReadCondHandleKey< MuonGM::MuonDetectorManager >
CaloCondBlobAlgs_fillNoiseFromASCII.hash
dictionary hash
Definition: CaloCondBlobAlgs_fillNoiseFromASCII.py:108
Muon::MuonLayerHashProviderTool::interfaceID
static const InterfaceID & interfaceID()
access to tool interface
Definition: MuonLayerHashProviderTool.h:51
Muon::MuonLayerHashProviderTool::RegionHashVec
std::array< HashVec, MuonStationIndex::sectorLayerHashMax()> RegionHashVec
Definition: MuonLayerHashProviderTool.h:31
Muon::MuonLayerHashProviderTool::RegionHashesPerSector::technologyRegionHashVecs
TechnologyRegionHashVec technologyRegionHashVecs
Definition: MuonLayerHashProviderTool.h:38
AthAlgTool
Definition: AthAlgTool.h:26
Muon::MuonLayerHashProviderTool::ATLAS_THREAD_SAFE
RegionHashesPerSectorVec m_regionHashesPerSector ATLAS_THREAD_SAFE
cachaed hash data structure
Definition: MuonLayerHashProviderTool.h:75
Muon::MuonLayerHashProviderTool::m_detMgrKey
SG::ReadCondHandleKey< MuonGM::MuonDetectorManager > m_detMgrKey
Definition: MuonLayerHashProviderTool.h:81
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
IMuonIdHelperSvc.h
Muon::MuonLayerHashProviderTool::techMax
static constexpr unsigned techMax
Definition: MuonLayerHashProviderTool.h:33
Muon::MuonStationIndex::toInt
constexpr int toInt(const EnumType enumVal)
Definition: MuonStationIndex.h:61
ServiceHandle< Muon::IMuonIdHelperSvc >
Identifier
Definition: IdentifierFieldParser.cxx:14