ATLAS Offline Software
Loading...
Searching...
No Matches
TileFragHash.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration
3*/
4
5
8#include <cassert>
9#include <cstring>
10
11// This class converts a Frag_ID into a integer, according to its
12// value of (ROS and drawer number).
13
14// default contructor
16 : m_size(0)
17 , m_offset(0)
19{
20 memset(m_lookup,0,sizeof(m_lookup));
21}
22
23void TileFragHash::initialize( const TileHWID * tileHWID, TYPE type )
24{
25 // std::cout << " TileFragHash Constructor "<< std::endl;
26
27 m_type = type;
28 m_size = 0;
29 if (!tileHWID) return;
30 m_int2id.clear();
31 m_int2id.reserve(tileHWID->drawer_hash_max());
32
33 for(int i = 0; i< m_table_size; ++i) { m_lookup[i]=-1; }
34
36 std::vector<HWIdentifier>::const_iterator first = tileHWID->drawer_begin();
37 std::vector<HWIdentifier>::const_iterator last = tileHWID->drawer_end();
38
39 switch (type) {
40 case Beam:
41 m_offset = 0;
42 for ( ; first!=last; ++first) {
43 ID id = tileHWID->frag(*first);
44 if (id >= 0x100) continue; // skip all real drawers
45 assert(id>=0 && id < m_table_size);
46
47 m_int2id.push_back(id);
48 m_lookup[id] = (m_size++);
49 }
50 // std::cout << " Number of valid Beam frag IDs "<< m_size << std::endl;
51 break;
52 default:
53 m_offset = (int)type * 0x1000;
54 for ( ; first!=last; ++first) {
55 ID id = tileHWID->frag(*first);
56 if (id < 0x100) continue; // skip Beam ROD frags
57 assert(id>=0 && id < m_table_size);
58
59 m_int2id.push_back(id);
60 m_lookup[id] = (m_size++);
61 }
62 // std::cout << " Number of valid drawer IDs "<< m_size << std::endl;
63 break;
64 }
65}
66
68{
69 assert(index>=0 && index < m_size);
70
71 return m_int2id[index];
72}
73
74int TileFragHash::hash (const ID& id) const
75{
76 assert(id>=0 && id < m_table_size);
77
78 return m_lookup[id];
79}
80
81
86{
87 switch (type) {
88#define CASE(X) case TileFragHash::X: return #X
94 CASE(MF);
98 CASE(Beam);
99#undef CASE
100 default: break;
101 };
102 return "UNKNOWN";
103}
#define CASE(X)
TYPE
initialize
void initialize(const TileHWID *tileHWID, TYPE type=Default)
int hash(const ID &id) const
Convert ID to int (same as the converter, but easier to call from python)
static std::string typeToString(TYPE type)
Printable representation of a type.
int m_size
total number of IDs
int m_lookup[m_table_size]
ID identifier(int i) const
reverse conversion
std::vector< ID > m_int2id
TYPE type() const
return hash type
static const int m_table_size
lookup table
Helper class for TileCal online (hardware) identifiers.
Definition TileHWID.h:49
int frag(const HWIdentifier &id) const
extract frag field from HW identifier
Definition TileHWID.h:181
std::vector< HWIdentifier >::const_iterator drawer_end() const
end iterator for drawer Identifiers
Definition TileHWID.h:294
std::vector< HWIdentifier >::const_iterator drawer_begin() const
begin iterator for drawer Identifiers
Definition TileHWID.h:290
size_type drawer_hash_max() const
drawer hash table max size
Definition TileHWID.h:268
Definition index.py:1