ATLAS Offline Software
Loading...
Searching...
No Matches
CaloCellClusterWeights.cxx
Go to the documentation of this file.
1/* Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration */
3
5
6#include <algorithm>
7
8#ifndef CELLCLUSTERLOOKUP
9#define CELLCLUSTERLOOKUP 200000
10#endif
11
17
21
23 : m_hashTable(cellClusterWeights.m_hashTable)
24{ }
25
27= default;
28
30{ return this->check(hash) ? std::get<1>(m_hashTable.at(hash)) : m_defaultValue; }
32{ return this->check(hash) ? std::get<1>( m_hashTable.at(hash)) : m_defaultValue; }
34{ return this->at(static_cast<size_t>(pCell->caloDDE()->calo_hash())); }
35
36bool CaloCellClusterWeights::fastCheck(size_t hash) const { return std::get<0>(m_hashTable.at(hash)); }
37bool CaloCellClusterWeights::fastCheck(const CaloCell* pCell) const { return this->fastCheck(static_cast<size_t>(pCell->caloDDE()->calo_hash())); }
38bool CaloCellClusterWeights::check(size_t hash) const { return hash < m_hashTable.size() && this->fastCheck(hash); }
39bool CaloCellClusterWeights::check(const CaloCell* pCell) const { return this->check(static_cast<size_t>(pCell->caloDDE()->calo_hash())); }
40
41void CaloCellClusterWeights::set(size_t hash,double value)
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}
52
53void CaloCellClusterWeights::set(const CaloCell* pCell,double value) { this->set(static_cast<size_t>(pCell->caloDDE()->calo_hash()),value); }
54
57 if ( hash < m_hashTable.size() ) { std::get<0>(m_hashTable[hash]) = false; std::get<1>(m_hashTable[hash]) = m_defaultValue; }
58}
#define CELLCLUSTERLOOKUP
bool check(size_t hash) const
Safe checking if cell is used by any cluster.
CaloCellClusterWeights()
Default constructor.
std::tuple< bool, weight_t > value_t
Type of payload.
void reset()
Reset the store.
bool fastCheck(size_t hash) const
Fast checking if cell is used by any cluster.
std::vector< double > weight_t
Type of weight.
weight_t m_defaultValue
Default (empty) entry.
virtual ~CaloCellClusterWeights()
Destructor.
size_t size() const
Store size.
const weight_t & at(size_t hash) const
Accessing value using function and hash.
store_t m_hashTable
Store implementation.
void clear()
Clear the store.
void set(size_t hash, double value)
const weight_t & operator[](size_t hash) const
Data object for each calorimeter readout cell.
Definition CaloCell.h:57
const CaloDetDescrElement * caloDDE() const
get pointer to CaloDetDescrElement (data member)
Definition CaloCell.h:321