ATLAS Offline Software
CaloCellClusterWeights.cxx
Go to the documentation of this file.
1 /* Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration */
3 
4 #include "CaloEvent/CaloCell.h"
5 
6 #include <algorithm>
7 
8 #ifndef CELLCLUSTERLOOKUP
9 #define CELLCLUSTERLOOKUP 200000
10 #endif
11 
13  : m_hashTable(size)
14 {
15  this->clear();
16 }
17 
20 { }
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 
36 bool CaloCellClusterWeights::fastCheck(size_t hash) const { return std::get<0>(m_hashTable.at(hash)); }
37 bool CaloCellClusterWeights::fastCheck(const CaloCell* pCell) const { return this->fastCheck(static_cast<size_t>(pCell->caloDDE()->calo_hash())); }
38 bool CaloCellClusterWeights::check(size_t hash) const { return hash < m_hashTable.size() && this->fastCheck(hash); }
39 bool CaloCellClusterWeights::check(const CaloCell* pCell) const { return this->check(static_cast<size_t>(pCell->caloDDE()->calo_hash())); }
40 
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 
53 void 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 }
CaloCellClusterWeights::~CaloCellClusterWeights
virtual ~CaloCellClusterWeights()
Destructor.
CaloCellClusterWeights::m_hashTable
store_t m_hashTable
Store implementation.
Definition: CaloCellClusterWeights.h:140
CaloCellClusterWeights::reset
void reset()
Reset the store.
Definition: CaloCellClusterWeights.cxx:59
CaloCellClusterWeights::weight_t
std::vector< double > weight_t
Type of weight.
Definition: CaloCellClusterWeights.h:28
CaloCell.h
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
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
python.setupRTTAlg.size
int size
Definition: setupRTTAlg.py:39
CaloCellClusterWeights::operator[]
const weight_t & operator[](size_t hash) const
Definition: CaloCellClusterWeights.cxx:29
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::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
CaloCellClusterWeights
Hash lookup of calibration weights for calorimeter cells.
Definition: CaloCellClusterWeights.h:23
CaloCell
Data object for each calorimeter readout cell.
Definition: CaloCell.h:57
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
CaloCellClusterWeights.h