ATLAS Offline Software
Public Member Functions | Private Attributes | List of all members
CaloIDHelper::HashGroup Class Reference

Manage a list of identifiers. More...

#include <CaloIDHelper.h>

Collaboration diagram for CaloIDHelper::HashGroup:

Public Member Functions

 HashGroup ()
 Constructor. More...
 
template<class T >
int init (T &parent, const std::string &type, const MultiRange &full_range, Identifier(T::*idfunc)(const ExpandedIdentifier &) const, size_type end_index)
 Initialize. More...
 
int init (const std::string &name, const std::set< Identifier > &ids, size_type end_index, IMessageSvc *msgSvc, const MultiRange *full_range=0)
 Initialize. More...
 
size_type hash_max () const
 Return one more than the largest hash code. More...
 
id_iterator begin () const
 Return a begin iterator over the group's Identifiers. More...
 
id_iterator end () const
 Return an end iterator over the group's Identifiers. More...
 
id_range range () const
 Return an iterator range over the group's Identifiers. More...
 
Identifier id (IdentifierHash hashId) const
 Return the identifier for a given hash code (no checking). More...
 
int get_hash (Identifier id, IdentifierHash &hash_id) const
 Look up the hash code corresponding to an Identifier. More...
 
IdentifierHash hash (Identifier id) const
 Look up the hash code corresponding to an Identifier. More...
 
const std::vector< Identifier > & ids () const
 Return a vector of all Identifiers for this group. More...
 
size_type end_index () const
 Return the ending index of the context for this group. More...
 
IdContext context () const
 Return the context for this group. More...
 

Private Attributes

std::vector< Identifierm_id_vec
 List of Identifiers for this group. More...
 
size_type m_end_index
 Ending index for this group's context. More...
 

Detailed Description

Manage a list of identifiers.

The identifiers are kept in sorted order, and the index of an identifier in this list defines its hash value. We supply methods for converting between identifiers and the hash value; we also keep track of the corresponding ID context.

Most calo ID helpers will use two of these: one for channels (cells) and one for regiosn.

Definition at line 61 of file CaloIDHelper.h.

Constructor & Destructor Documentation

◆ HashGroup()

CaloIDHelper::HashGroup::HashGroup ( )

Constructor.

Starts in an uninitialized state.

Definition at line 25 of file CaloIDHelper.cxx.

26  : m_end_index(99999)
27 {
28 }

Member Function Documentation

◆ begin()

id_iterator CaloIDHelper::HashGroup::begin ( ) const

Return a begin iterator over the group's Identifiers.

◆ context()

IdContext CaloIDHelper::HashGroup::context ( ) const

Return the context for this group.

Definition at line 83 of file CaloIDHelper.cxx.

84 {
86  return IdContext (id, 0, m_end_index);
87 }

◆ end()

id_iterator CaloIDHelper::HashGroup::end ( ) const

Return an end iterator over the group's Identifiers.

◆ end_index()

size_type CaloIDHelper::HashGroup::end_index ( ) const

Return the ending index of the context for this group.

◆ get_hash()

int CaloIDHelper::HashGroup::get_hash ( Identifier  id,
IdentifierHash hash_id 
) const

Look up the hash code corresponding to an Identifier.

Look up the hash code corresponding ot an Identifier.

Uses binary search.

Parameters
idThe identifier to look up.
[out]hash_idThe corresponding hash code.
Returns
0 if the Identifier was found; non-zero otherwise.

Definition at line 68 of file CaloIDHelper.cxx.

70 {
71  std::vector<Identifier>::const_iterator it = std::lower_bound(m_id_vec.begin(),m_id_vec.end(),id);
72  if ( it != m_id_vec.end() ){
73  hash_id = it - m_id_vec.begin();
74  return 0;
75  }
76  return 1;
77 }

◆ hash()

IdentifierHash CaloIDHelper::HashGroup::hash ( Identifier  id) const

Look up the hash code corresponding to an Identifier.

Uses binary search.

Parameters
idThe identifier to look up.
Returns
The corresponding hash code. An invalid IdentifierHash will be returned if the Identifier is not found.

◆ hash_max()

size_type CaloIDHelper::HashGroup::hash_max ( ) const

Return one more than the largest hash code.

◆ id()

Identifier CaloIDHelper::HashGroup::id ( IdentifierHash  hashId) const

Return the identifier for a given hash code (no checking).

◆ ids()

const std::vector<Identifier>& CaloIDHelper::HashGroup::ids ( ) const

Return a vector of all Identifiers for this group.

◆ init() [1/2]

int CaloIDHelper::HashGroup::init ( const std::string &  name,
const std::set< Identifier > &  ids,
size_type  end_index,
IMessageSvc *  msgSvc,
const MultiRange full_range = 0 
)

Initialize.

Parameters
nameName of this group (only for error reporting).
idsSet of Identifiers comprising this group.
end_indexThe ending index for the context for this group. @parma msgSvc The global message service (may be 0, only for error reporting).
full_rangeThe MultiRange corresponding to this group. If supplied, the side of the ids set is checked against the range's cardinality.
Returns
0 on success; non-zero on failure.

Definition at line 43 of file CaloIDHelper.cxx.

48 {
50  if (full_range && full_range->cardinality() != ids.size()) {
51  MsgStream log (msgSvc, "CaloIDHelper");
52  log << MSG::ERROR << name << " set size " << ids.size()
53  << " not equal to hash max " << full_range->cardinality() << endmsg;
54  return 1;
55  }
56  m_id_vec.assign (ids.begin(), ids.end());
57  return 0;
58 }

◆ init() [2/2]

template<class T >
int CaloIDHelper::HashGroup::init ( T &  parent,
const std::string &  type,
const MultiRange full_range,
Identifier(T::*)(const ExpandedIdentifier &) const  idfunc,
size_type  end_index 
)

Initialize.

Parameters
parentThe parent ID helper (in which idfunc is defined).
typeA string to add on to the name.
full_rangeThe MultiRange for to this group.
idfuncFunction to convert from an ExpandedIdentifier to an Identifier for this group.
end_indexThe ending index for the context for this group.
Returns
0 on success; non-zero on failure.

◆ range()

id_range CaloIDHelper::HashGroup::range ( ) const

Return an iterator range over the group's Identifiers.

Member Data Documentation

◆ m_end_index

size_type CaloIDHelper::HashGroup::m_end_index
private

Ending index for this group's context.

Definition at line 157 of file CaloIDHelper.h.

◆ m_id_vec

std::vector<Identifier> CaloIDHelper::HashGroup::m_id_vec
private

List of Identifiers for this group.

Definition at line 154 of file CaloIDHelper.h.


The documentation for this class was generated from the following files:
CaloIDHelper::HashGroup::m_id_vec
std::vector< Identifier > m_id_vec
List of Identifiers for this group.
Definition: CaloIDHelper.h:154
CaloIDHelper::HashGroup::m_end_index
size_type m_end_index
Ending index for this group's context.
Definition: CaloIDHelper.h:157
CaloIDHelper::HashGroup::end_index
size_type end_index() const
Return the ending index of the context for this group.
skel.it
it
Definition: skel.GENtoEVGEN.py:423
CaloIDHelper::HashGroup::id
Identifier id(IdentifierHash hashId) const
Return the identifier for a given hash code (no checking).
ExpandedIdentifier
Definition: DetectorDescription/Identifier/Identifier/ExpandedIdentifier.h:108
CaloIDHelper::name
std::string name() const
Return the name for this helper.
CaloIDHelper::HashGroup::ids
const std::vector< Identifier > & ids() const
Return a vector of all Identifiers for this group.
endmsg
#define endmsg
Definition: AnalysisConfig_Ntuple.cxx:63
CaloIDHelper::msgSvc
IMessageSvc * msgSvc()
Return the message service for this helper (may be null).
python.CaloCondTools.log
log
Definition: CaloCondTools.py:20
MultiRange::cardinality
size_type cardinality() const
Computes a possible cardinality from all ranges.
Definition: DetectorDescription/Identifier/src/Range.cxx:2503
IdContext
class IdContext
Definition: IdContext.h:34