|
ATLAS Offline Software
|
Go to the documentation of this file.
5 #ifndef MUONCALIBIDENTIFIER_IDENTIFIERHASHTABLE_H
6 #define MUONCALIBIDENTIFIER_IDENTIFIERHASHTABLE_H
18 #include "GaudiKernel/MsgStream.h"
43 typedef typename T::IdentifierType
IdType;
71 void dump( std::ostream&
os = std::cout )
const;
85 : m_idToHash(idFields)
91 #ifdef IDENTIFIERHASHTABLE_DEBUG
93 log<<
MSG::DEBUG<<
"IdentifierHashTable<T>::addEntry(0x" << std::hex <<
id << std::dec <<
")"<<
endmsg;
96 #ifdef IDENTIFIERHASHTABLE_DEBUG
101 #ifdef IDENTIFIERHASHTABLE_DEBUG
106 #ifdef IDENTIFIERHASHTABLE_DEBUG
112 #ifdef IDENTIFIERHASHTABLE_DEBUG
148 unsigned int idToHashSize =
m_idToHash.size();
151 log<<MSG::WARNING<<
"IdentifierHashTable<T>::checkValidity() idToHash size (" << idToHashSize <<
") not equal to hashToId size (" <<
m_hashToId.size() <<
")"<<
endmsg;
157 log<<MSG::WARNING<<
"IdentifierHashTable<T>::checkValidity() Table is empty."<<
endmsg;
160 #ifdef IDENTIFIERHASHTABLE_DEBUG
164 unsigned int nErrors = 0;
169 if ( gotHash != tryHash ) {
170 #ifndef IDENTIFIERHASHTABLE_DEBUG
173 log<<MSG::WARNING<<
"IdentifierHashTable<T>::checkValidity() getIdentifier(" << tryHash <<
")=0x" << std::hex <<
id << std::dec <<
" whereas getHash(" << std::hex <<
id << std::dec <<
")=" << gotHash<<
endmsg;
176 #ifdef IDENTIFIERHASHTABLE_DEBUG
177 log<<
MSG::DEBUG<<
"hash=" <<
i <<
" <--> id=0x" << std::hex <<
id << std::dec <<
": OK" <<
endmsg;
181 #ifdef IDENTIFIERHASHTABLE_DEBUG
183 log<<MSG::WARNING<<
"IdentifierHashTable<T>::checkValidity() table contains " << nErrors <<
" errors." <<
endmsg;
189 if ( nErrors )
return false;
198 for (
int i = 0;
i <
n; ++
i ) {
201 os <<
"ID=0x" << std::hex <<
id << std::dec <<
" fields";
205 os <<
"IdentifierHashTable has " <<
n <<
" valid entries and "
206 << nTotal -
n <<
" wasted entries" << std::endl;
211 std::ostringstream oss;
216 #endif // MUONCALIBIDENTIFIER_IDENTIFIERHASHTABLE_H
The IdentifierToHash table.
IdentifierHashTable(const T &idFields)
Make empty hash table initialised with idFields object.
singleton-like access to IMessageSvc via open function and helper
HashType getHash(const IdType &id) const
Get hash from 0 to size()-1.
static HashType defaultHashValue()
Helper function to get a properly initialised hash.
T::HashType HashType
define the type HashType
bool isValid(const T &p)
Av: we implement here an ATLAS-sepcific convention: all particles which are 99xxxxx are fine.
IMessageSvc * getMessageSvc(bool quiet=false)
unsigned int size() const
Number of hashes in the table.
void clear()
Clear the hashtable.
bool checkValidity() const
Check that the table is internally consistent.
IdType getIdentifier(const HashType &hash) const
Get identifier from hash.
HashType addEntry(const IdType &id)
Add an identifier to the table.
IdentifierHashTable()
Default constructor makes empty hash table with default idFields object.
IdentifierToHash< T > m_idToHash
void dump(std::ostream &os=std::cout) const
Dump complete table to output stream.
std::vector< IdType > m_hashToId
T::IdentifierType IdType
define the type IdType
std::string dumpToString() const
Dump complete table into a string.
static HashType defaultHashValue()
Helper function to get a properly initialised hash.