ATLAS Offline Software
Loading...
Searching...
No Matches
LArRodIdHash.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
3*/
4
6
7#include "eformat/SourceIdentifier.h"
9
10#include <stdexcept>
11
12using eformat::helper::SourceIdentifier;
13
14
15void LArRodIdHash::initialize( int offset, const std::vector<HWIdentifier>& roms ) {
16
18
19 LArReadoutModuleService larROMService;
20 std::vector<ID> rmod;
21 rmod.reserve(roms.size());
22
23 for(const HWIdentifier& mId : roms) {
24 SourceIdentifier sid{static_cast<eformat::SubDetector>(larROMService.subDet(mId)),
25 static_cast<uint8_t>(larROMService.rodFragId(mId))};
26 const uint32_t rod_id = sid.code();
27 rmod.push_back(rod_id);
28 }
29
30 size_t n = 0;
31 for (ID id : rmod) {
32 m_lookup[id] = n;
33 m_int2id.push_back(id);
34 ++n;
35 }
36}
37
38
39size_t LArRodIdHash::operator() (ID id) const {
40
41 const auto it = m_lookup.find(id);
42 if(it!=m_lookup.end()) return it->second;
43
44 throw std::out_of_range("LArRodIdHash: invalid Rod number" + std::to_string(id));
45
46}
Service for creating and interpreting LAr readout modules identifiers.
static int subDet(const HWIdentifier &id)
return sub-detector identifier
static int rodFragId(const HWIdentifier &id)
return ROD fragment identifier ( == ROL == ROB identifier )
unsigned int ID
definition of ID type
std::unordered_map< ID, size_t > m_lookup
lookup map
std::vector< ID > m_int2id
reverse lookup
size_t operator()(ID id) const
convert ID to index throws std::out_of_range if not found
void initialize(int offset, const std::vector< HWIdentifier > &roms)
Initialize.
int offset() const
return offset