ATLAS Offline Software
Public Member Functions | Static Public Member Functions | Private Attributes | List of all members
CaloCellClusterWeights Class Reference

Hash lookup of calibration weights for calorimeter cells. More...

#include <CaloCellClusterWeights.h>

Collaboration diagram for CaloCellClusterWeights:

Public Types

Storage and payload types
typedef std::vector< double > weight_t
 Type of weight. More...
 
typedef std::tuple< bool, weight_tvalue_t
 Type of payload. More...
 
typedef std::vector< value_tstore_t
 Store type. More...
 
typedef store_t::const_iterator const_iterator
 Iterator type for const access. More...
 
typedef store_t::iterator iterator
 Iterator type. More...
 

Public Member Functions

 CaloCellClusterWeights ()
 Default constructor. More...
 
 CaloCellClusterWeights (size_t size)
 Constructor with client-defined size. More...
 
 CaloCellClusterWeights (const CaloCellClusterWeights &cellClusterWeights)
 Copy constructor. More...
 
virtual ~CaloCellClusterWeights ()
 Destructor. More...
 
Random access to payload

Accessing value using operator

Returns
Stored value at given index if index is valid, else payload default value (0).
Parameters
hashindex (calorimeter cell hash id)
const weight_toperator[] (size_t hash) const
 
const weight_tat (size_t hash) const
 Accessing value using function and hash. More...
 
const weight_tat (const CaloCell *pCell) const
 Accessing value using function and cell pointer. More...
 
bool check (size_t hash) const
 Safe checking if cell is used by any cluster. More...
 
bool check (const CaloCell *pCell) const
 Safe checking if cell is used by any cluster. More...
 
bool fastCheck (size_t hash) const
 Fast checking if cell is used by any cluster. More...
 
bool fastCheck (const CaloCell *pCell) const
 Fast checking if cell is used by any cluster. More...
 
Store modifiers

Loading a value by hash id

This method overwrites the stored value at the given index. It also sets the "used" flag in the store for the cell.

Parameters
hashindex in store
valuevalue to be stored at index
void set (size_t hash, double value)
 
void set (const CaloCell *pCell, double value)
 Loading a value by cell pointer. More...
 
void reset ()
 Reset the store. More...
 
void clear ()
 Clear the store. More...
 
void clear (size_t hash)
 Clear a specific entry in the store. More...
 
Store parameters
size_t size () const
 Store size. More...
 
size_t reserve () const
 Reserved memory. More...
 
Iterators
const_iterator begin () const
 Constant access iterator pointing to beginning of the store. More...
 
const_iterator end () const
 Constant iterator indicating the end of the store. More...
 
iterator begin ()
 Access iterator pointing to beginning of the store. More...
 
iterator end ()
 Iterator indicating the end of the store. More...
 
Store access
const store_tstore () const
 Read-only access to underlying store. More...
 
store_tstore ()
 Read/write access to underlying store. More...
 

Static Public Member Functions

static std::string key (const std::string &pref)
 Construct a SG key for this object. More...
 

Private Attributes

store_t m_hashTable
 Store implementation. More...
 
weight_t m_defaultValue { weight_t() }
 Default (empty) entry. More...
 

Detailed Description

Hash lookup of calibration weights for calorimeter cells.

This object wraps a random access lookup of calibration weights based on the hash id of a calorimeter cell. It is meant to provide these weights to several tools, thus e.g. reducing the number of searches for cells in topo-clusters.

The data object reserves a fixed memory segment sufficient to store one weight per cell, and is of a fixed size which is defaulted to the total number of calorimeter cells, but can also be set at construction.

Definition at line 22 of file CaloCellClusterWeights.h.

Member Typedef Documentation

◆ const_iterator

typedef store_t::const_iterator CaloCellClusterWeights::const_iterator

Iterator type for const access.

Definition at line 31 of file CaloCellClusterWeights.h.

◆ iterator

typedef store_t::iterator CaloCellClusterWeights::iterator

Iterator type.

Definition at line 32 of file CaloCellClusterWeights.h.

◆ store_t

Store type.

Definition at line 30 of file CaloCellClusterWeights.h.

◆ value_t

typedef std::tuple<bool,weight_t> CaloCellClusterWeights::value_t

Type of payload.

Definition at line 29 of file CaloCellClusterWeights.h.

◆ weight_t

typedef std::vector<double> CaloCellClusterWeights::weight_t

Type of weight.

Definition at line 28 of file CaloCellClusterWeights.h.

Constructor & Destructor Documentation

◆ CaloCellClusterWeights() [1/3]

CaloCellClusterWeights::CaloCellClusterWeights ( )

Default constructor.

The constructed data object provides a reserved and sized store appropriate for the total number of cells in the calorimeter. The store is pre-filled with the default payload value (0).

Definition at line 18 of file CaloCellClusterWeights.cxx.

◆ CaloCellClusterWeights() [2/3]

CaloCellClusterWeights::CaloCellClusterWeights ( size_t  size)

Constructor with client-defined size.

A store with the specified size is created and pre-filled with the default payload value (0).

Parameters
sizerequested store size

Definition at line 12 of file CaloCellClusterWeights.cxx.

13  : m_hashTable(size)
14 {
15  this->clear();
16 }

◆ CaloCellClusterWeights() [3/3]

CaloCellClusterWeights::CaloCellClusterWeights ( const CaloCellClusterWeights cellClusterWeights)

Copy constructor.

Definition at line 22 of file CaloCellClusterWeights.cxx.

23  : m_hashTable(cellClusterWeights.m_hashTable)
24 { }

◆ ~CaloCellClusterWeights()

CaloCellClusterWeights::~CaloCellClusterWeights ( )
virtualdefault

Destructor.

Member Function Documentation

◆ at() [1/2]

const CaloCellClusterWeights::weight_t & CaloCellClusterWeights::at ( const CaloCell pCell) const

Accessing value using function and cell pointer.

Returns
Stored value at given index if index is valid, else payload default value (0).
Parameters
hashindex (calorimeter cell hash id)

Definition at line 33 of file CaloCellClusterWeights.cxx.

34 { return this->at(static_cast<size_t>(pCell->caloDDE()->calo_hash())); }

◆ at() [2/2]

const CaloCellClusterWeights::weight_t & CaloCellClusterWeights::at ( size_t  hash) const

Accessing value using function and hash.

Returns
Stored value at given index if index is valid, else payload default value (0).
Parameters
hashindex (calorimeter cell hash id)

Definition at line 31 of file CaloCellClusterWeights.cxx.

32 { return this->check(hash) ? std::get<1>( m_hashTable.at(hash)) : m_defaultValue; }

◆ begin() [1/2]

CaloCellClusterWeights::iterator CaloCellClusterWeights::begin ( )
inline

Access iterator pointing to beginning of the store.

Definition at line 147 of file CaloCellClusterWeights.h.

147 { return m_hashTable.begin(); }

◆ begin() [2/2]

CaloCellClusterWeights::const_iterator CaloCellClusterWeights::begin ( ) const
inline

Constant access iterator pointing to beginning of the store.

Definition at line 146 of file CaloCellClusterWeights.h.

146 { return m_hashTable.begin(); }

◆ check() [1/2]

bool CaloCellClusterWeights::check ( const CaloCell pCell) const

Safe checking if cell is used by any cluster.

Returns
true if cell is part of any cluster and has valid hash index

Definition at line 39 of file CaloCellClusterWeights.cxx.

39 { return this->check(static_cast<size_t>(pCell->caloDDE()->calo_hash())); }

◆ check() [2/2]

bool CaloCellClusterWeights::check ( size_t  hash) const

Safe checking if cell is used by any cluster.

Returns
true if cell is part of any cluster and has valid hash index

Definition at line 38 of file CaloCellClusterWeights.cxx.

38 { return hash < m_hashTable.size() && this->fastCheck(hash); }

◆ clear() [1/2]

void CaloCellClusterWeights::clear ( )

Clear the store.

All stored values are overwritten with the default payload value (0).

Definition at line 55 of file CaloCellClusterWeights.cxx.

55 { std::fill(m_hashTable.begin(),m_hashTable.end(),value_t(false,m_defaultValue)); }

◆ clear() [2/2]

void CaloCellClusterWeights::clear ( size_t  hash)

Clear a specific entry in the store.

The value stored at the given index is overwritten with the default payload value (0).

Parameters
hashindex in store

Definition at line 56 of file CaloCellClusterWeights.cxx.

56  {
57  if ( hash < m_hashTable.size() ) { std::get<0>(m_hashTable[hash]) = false; std::get<1>(m_hashTable[hash]) = m_defaultValue; }
58 }

◆ end() [1/2]

CaloCellClusterWeights::iterator CaloCellClusterWeights::end ( )
inline

Iterator indicating the end of the store.

Definition at line 150 of file CaloCellClusterWeights.h.

150 { return m_hashTable.end(); }

◆ end() [2/2]

CaloCellClusterWeights::const_iterator CaloCellClusterWeights::end ( ) const
inline

Constant iterator indicating the end of the store.

Definition at line 149 of file CaloCellClusterWeights.h.

149 { return m_hashTable.end(); }

◆ fastCheck() [1/2]

bool CaloCellClusterWeights::fastCheck ( const CaloCell pCell) const

Fast checking if cell is used by any cluster.

Returns
true if cell is part of any cluster

Definition at line 37 of file CaloCellClusterWeights.cxx.

37 { return this->fastCheck(static_cast<size_t>(pCell->caloDDE()->calo_hash())); }

◆ fastCheck() [2/2]

bool CaloCellClusterWeights::fastCheck ( size_t  hash) const

Fast checking if cell is used by any cluster.

Returns
true if cell is part of any cluster

Definition at line 36 of file CaloCellClusterWeights.cxx.

36 { return std::get<0>(m_hashTable.at(hash)); }

◆ key()

std::string CaloCellClusterWeights::key ( const std::string &  pref)
inlinestatic

Construct a SG key for this object.

Definition at line 158 of file CaloCellClusterWeights.h.

158 { return pref+std::string("_CCW"); }

◆ operator[]()

const CaloCellClusterWeights::weight_t & CaloCellClusterWeights::operator[] ( size_t  hash) const

Definition at line 29 of file CaloCellClusterWeights.cxx.

30 { return this->check(hash) ? std::get<1>(m_hashTable.at(hash)) : m_defaultValue; }

◆ reserve()

size_t CaloCellClusterWeights::reserve ( ) const
inline

Reserved memory.

Definition at line 153 of file CaloCellClusterWeights.h.

153 { return m_hashTable.capacity(); }

◆ reset()

void CaloCellClusterWeights::reset ( )

Reset the store.

All stored values are overwritten with the default payload value (0).

Definition at line 59 of file CaloCellClusterWeights.cxx.

59 { this->clear(); }

◆ set() [1/2]

void CaloCellClusterWeights::set ( const CaloCell pCell,
double  value 
)

Loading a value by cell pointer.

This method overwrites the stored value at the given index. It also sets the "used" flag in the store for the cell.

Parameters
hashindex in store
valuevalue to be stored at index

Definition at line 53 of file CaloCellClusterWeights.cxx.

53 { this->set(static_cast<size_t>(pCell->caloDDE()->calo_hash()),value); }

◆ set() [2/2]

void CaloCellClusterWeights::set ( size_t  hash,
double  value 
)

Definition at line 41 of file CaloCellClusterWeights.cxx.

42 {
43  if ( hash < m_hashTable.size() ) {
44  if ( this->fastCheck(hash) ) {
45  std::get<1>(m_hashTable[hash]).push_back(value);
46  } else {
47  std::get<0>(m_hashTable[hash]) = true;
48  std::get<1>(m_hashTable[hash]).push_back(value);
49  }
50  }
51 }

◆ size()

size_t CaloCellClusterWeights::size ( ) const
inline

Store size.

Definition at line 152 of file CaloCellClusterWeights.h.

152 { return m_hashTable.size(); }

◆ store() [1/2]

CaloCellClusterWeights::store_t & CaloCellClusterWeights::store ( )
inline

Read/write access to underlying store.

Definition at line 156 of file CaloCellClusterWeights.h.

156 { return m_hashTable; }

◆ store() [2/2]

const CaloCellClusterWeights::store_t & CaloCellClusterWeights::store ( ) const
inline

Read-only access to underlying store.

Definition at line 155 of file CaloCellClusterWeights.h.

155 { return m_hashTable; }

Member Data Documentation

◆ m_defaultValue

weight_t CaloCellClusterWeights::m_defaultValue { weight_t() }
private

Default (empty) entry.

Definition at line 141 of file CaloCellClusterWeights.h.

◆ m_hashTable

store_t CaloCellClusterWeights::m_hashTable
private

Store implementation.

Definition at line 140 of file CaloCellClusterWeights.h.


The documentation for this class was generated from the following files:
CaloCellClusterWeights::m_hashTable
store_t m_hashTable
Store implementation.
Definition: CaloCellClusterWeights.h:140
athena.value
value
Definition: athena.py:124
CaloCellClusterWeights::check
bool check(size_t hash) const
Safe checking if cell is used by any cluster.
Definition: CaloCellClusterWeights.cxx:38
TestSUSYToolsAlg.pref
pref
Definition: TestSUSYToolsAlg.py:80
CELLCLUSTERLOOKUP
#define CELLCLUSTERLOOKUP
Definition: CaloCellClusterWeights.cxx:9
CaloCellClusterWeights::fastCheck
bool fastCheck(size_t hash) const
Fast checking if cell is used by any cluster.
Definition: CaloCellClusterWeights.cxx:36
CaloCellClusterWeights::set
void set(size_t hash, double value)
Definition: CaloCellClusterWeights.cxx:41
CaloCellClusterWeights::at
const weight_t & at(size_t hash) const
Accessing value using function and hash.
Definition: CaloCellClusterWeights.cxx:31
CaloDetDescrElement::calo_hash
IdentifierHash calo_hash() const
cell calo hash
Definition: Calorimeter/CaloDetDescr/CaloDetDescr/CaloDetDescrElement.h:412
CaloCell::caloDDE
const CaloDetDescrElement * caloDDE() const
get pointer to CaloDetDescrElement (data member)
Definition: CaloCell.h:305
CaloCellClusterWeights::size
size_t size() const
Store size.
Definition: CaloCellClusterWeights.h:152
CaloCellClusterWeights::value_t
std::tuple< bool, weight_t > value_t
Type of payload.
Definition: CaloCellClusterWeights.h:29
CaloCellClusterWeights::clear
void clear()
Clear the store.
Definition: CaloCellClusterWeights.cxx:55
fill
void fill(H5::Group &out_file, size_t iterations)
Definition: test-hdf5-writer.cxx:95
CaloCondBlobAlgs_fillNoiseFromASCII.hash
dictionary hash
Definition: CaloCondBlobAlgs_fillNoiseFromASCII.py:109
CaloCellClusterWeights::CaloCellClusterWeights
CaloCellClusterWeights()
Default constructor.
Definition: CaloCellClusterWeights.cxx:18
CaloCellClusterWeights::m_defaultValue
weight_t m_defaultValue
Default (empty) entry.
Definition: CaloCellClusterWeights.h:141