|
ATLAS Offline Software
|
Go to the documentation of this file.
5 #ifndef MUONCALIBIDENTIFIER_IDENTIFIERTOHASH_H
6 #define MUONCALIBIDENTIFIER_IDENTIFIERTOHASH_H
18 #include "GaudiKernel/MsgStream.h"
49 typedef typename T::IdentifierType
IdType;
51 typedef typename T::HashType
HashType;
56 return T::defaultHash();
61 template <
unsigned int N,
class K >
66 #ifdef IDENTIFIERTOHASH_DEBUG
74 #ifdef IDENTIFIERTOHASH_DEBUG
87 #ifdef IDENTIFIERTOHASH_DEBUG
95 #ifdef IDENTIFIERTOHASH_DEBUG
109 template <
unsigned int N,
class K>
110 class RecursiveRangeCheck {
114 bool bOK =
obj.isInRange(
idx );
115 #ifdef IDENTIFIERTOHASH_DEBUG
128 class RecursiveRangeCheck<1,K> {
132 bool bOK =
obj.isInRange(
idx );
133 #ifdef IDENTIFIERTOHASH_DEBUG
147 class RecursiveRangeCheck<0,K> {
160 unsigned int size()
const;
179 void dump( std::ostream&
os = std::cout )
const;
195 : m_idFields( idFields ), m_entries(0)
202 #ifdef IDENTIFIERTOHASH_DEBUG
204 log<<
MSG::DEBUG<<
"IdentifierToHash<T>::addEntry(0x" << std::hex <<
id << std::dec <<
"," << aHash <<
")"<<
endmsg;
207 #ifdef IDENTIFIERTOHASH_DEBUG
212 m_idFields.setAll(
id );
218 RecursiveIndexCall< NFIELDS, ArrayType >::getRef(
m_data, m_idFields );
220 if ( hashRef != defaultHashValue() ) {
221 #ifdef IDENTIFIERTOHASH_DEBUG
222 log<<MSG::WARNING<<
"id already taken by hash=" << hashRef <<
". Nothing added."<<
endmsg;
228 #ifdef IDENTIFIERTOHASH_DEBUG
240 HashType aHash = m_entries;
241 if ( !addEntry(
id, aHash ) )
return defaultHashValue();
248 if ( !
T::isValid(
id ) )
return defaultHashValue();
249 m_idFields.setAll(
id );
252 return defaultHashValue();
271 return m_data.totalSize();
276 std::ostream&
os )
const {
277 m_idFields.setAll(
id );
278 m_data.dumpOneEntry( m_idFields,
os );
283 m_idFields.setAll(
id );
284 return m_data.dumpOneEntryToString( m_idFields );
294 return m_data.dumpToString();
298 #endif // MUONCALIBIDENTIFIER_IDENTIFIERTOHASH_H
void dumpOneEntry(const IdType &id, std::ostream &os) const
Dump one entry for given id to os.
HashType getHash(const IdType &id) const
Get hash from 0 to size()-1.
The IdentifierToHash table.
singleton-like access to IMessageSvc via open function and helper
static HashType defaultHashValue()
Helper function to get a properly initialised hash.
std::pair< long int, long int > indices
T::IdentifierType IdType
define type IdType
static const K::ValueType & getConstRef(const K &obj, const T &indices)
bool isValid(const T &p)
Av: we implement here an ATLAS-sepcific convention: all particles which are 99xxxxx are fine.
std::string dumpToString() const
Dump complete table into a string.
IMessageSvc * getMessageSvc(bool quiet=false)
void clear()
Clear the hashtable.
static bool isInRange(const K &obj, const T &indices)
std::string dumpOneEntryToString(const IdType &id) const
Dump one entry for given id to a string.
static K::ValueType & getRef(K &obj, const T &indices)
Helper class for one-go recursive range check on all indices.
Helper class for IdentifierToHash to automate recursive index call.
unsigned int totalSize() const
Total number of hashes in the table.
unsigned int size() const
Number of valid hashes in the table.
void dump(std::ostream &os=std::cout) const
Dump complete table to output stream.
HashType addEntry(const IdType &id)
Add an identifier to the table, and return the hash value belonging to it.
T::HashType HashType
define type HashType
MultiDimArray< T, NFIELDS > ArrayType
define type ArrayType
IdentifierToHash()
Default constructor makes empty hash table and creates default idFields object.