ATLAS Offline Software
Loading...
Searching...
No Matches
LArRodIdHash Class Reference

class that provides LArReadoutModuleID to integer hash ID mapping. More...

#include <LArRodIdHash.h>

Collaboration diagram for LArRodIdHash:

Public Types

using ID = unsigned int
 definition of ID type

Public Member Functions

void initialize (int offset, const std::vector< HWIdentifier > &roms)
 Initialize.
size_t operator() (ID id) const
 convert ID to index throws std::out_of_range if not found
size_t max () const
 return maximum number of IDs
ID identifier (size_t i) const
 reverse conversion
int offset () const
 return offset

Private Attributes

std::unordered_map< ID, size_t > m_lookup
 lookup map
std::vector< IDm_int2id
 reverse lookup
int m_offset {0}

Detailed Description

class that provides LArReadoutModuleID to integer hash ID mapping.

Definition at line 25 of file LArRodIdHash.h.

Member Typedef Documentation

◆ ID

using LArRodIdHash::ID = unsigned int

definition of ID type

Definition at line 30 of file LArRodIdHash.h.

Member Function Documentation

◆ identifier()

ID LArRodIdHash::identifier ( size_t i) const
inline

reverse conversion

Definition at line 43 of file LArRodIdHash.h.

43{ return m_int2id[i]; }
std::vector< ID > m_int2id
reverse lookup

◆ initialize()

void LArRodIdHash::initialize ( int offset,
const std::vector< HWIdentifier > & roms )

Initialize.

Here real map is built

Definition at line 15 of file LArRodIdHash.cxx.

15 {
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}
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
int offset() const
return offset
setEventNumber uint32_t

◆ max()

size_t LArRodIdHash::max ( ) const
inline

return maximum number of IDs

Definition at line 40 of file LArRodIdHash.h.

40{ return m_int2id.size(); }

◆ offset()

int LArRodIdHash::offset ( ) const
inline

return offset

Definition at line 46 of file LArRodIdHash.h.

46{ return m_offset; }

◆ operator()()

size_t LArRodIdHash::operator() ( ID id) const

convert ID to index throws std::out_of_range if not found

Definition at line 39 of file LArRodIdHash.cxx.

39 {
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}

Member Data Documentation

◆ m_int2id

std::vector<ID> LArRodIdHash::m_int2id
private

reverse lookup

Definition at line 54 of file LArRodIdHash.h.

◆ m_lookup

std::unordered_map<ID, size_t> LArRodIdHash::m_lookup
private

lookup map

Definition at line 51 of file LArRodIdHash.h.

◆ m_offset

int LArRodIdHash::m_offset {0}
private

Definition at line 56 of file LArRodIdHash.h.

56{0};

The documentation for this class was generated from the following files: