ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
Calorimeter
CaloEvent
src
CaloCellClusterWeights.cxx
Go to the documentation of this file.
1
/* Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration */
2
#include "
CaloEvent/CaloCellClusterWeights.h
"
3
4
#include "
CaloEvent/CaloCell.h
"
5
6
#include <algorithm>
7
8
#ifndef CELLCLUSTERLOOKUP
9
#define CELLCLUSTERLOOKUP 200000
10
#endif
11
12
CaloCellClusterWeights::CaloCellClusterWeights
(
size_t
size
)
13
:
m_hashTable
(
size
)
14
{
15
this->
clear
();
16
}
17
18
CaloCellClusterWeights::CaloCellClusterWeights
()
19
:
CaloCellClusterWeights
(
CELLCLUSTERLOOKUP
)
20
{ }
21
22
CaloCellClusterWeights::CaloCellClusterWeights
(
const
CaloCellClusterWeights
& cellClusterWeights)
23
:
m_hashTable
(cellClusterWeights.
m_hashTable
)
24
{ }
25
26
CaloCellClusterWeights::~CaloCellClusterWeights
()
27
=
default
;
28
29
const
CaloCellClusterWeights::weight_t
&
CaloCellClusterWeights::operator[]
(
size_t
hash)
const
30
{
return
this->
check
(hash) ? std::get<1>(
m_hashTable
.at(hash)) :
m_defaultValue
; }
31
const
CaloCellClusterWeights::weight_t
&
CaloCellClusterWeights::at
(
size_t
hash)
const
32
{
return
this->
check
(hash) ? std::get<1>(
m_hashTable
.at(hash)) :
m_defaultValue
; }
33
const
CaloCellClusterWeights::weight_t
&
CaloCellClusterWeights::at
(
const
CaloCell
* pCell)
const
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
41
void
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
53
void
CaloCellClusterWeights::set
(
const
CaloCell
* pCell,
double
value) { this->
set
(
static_cast<
size_t
>
(pCell->
caloDDE
()->
calo_hash
()),value); }
54
55
void
CaloCellClusterWeights::clear
() { std::fill(
m_hashTable
.begin(),
m_hashTable
.end(),
value_t
(
false
,
m_defaultValue
)); }
56
void
CaloCellClusterWeights::clear
(
size_t
hash) {
57
if
( hash <
m_hashTable
.size() ) { std::get<0>(
m_hashTable
[hash]) =
false
; std::get<1>(
m_hashTable
[hash]) =
m_defaultValue
; }
58
}
59
void
CaloCellClusterWeights::reset
() { this->
clear
(); }
CELLCLUSTERLOOKUP
#define CELLCLUSTERLOOKUP
Definition
CaloCellClusterWeights.cxx:9
CaloCellClusterWeights.h
CaloCell.h
CaloCellClusterWeights::check
bool check(size_t hash) const
Safe checking if cell is used by any cluster.
Definition
CaloCellClusterWeights.cxx:38
CaloCellClusterWeights::CaloCellClusterWeights
CaloCellClusterWeights()
Default constructor.
Definition
CaloCellClusterWeights.cxx:18
CaloCellClusterWeights::value_t
std::tuple< bool, weight_t > value_t
Type of payload.
Definition
CaloCellClusterWeights.h:29
CaloCellClusterWeights::reset
void reset()
Reset the store.
Definition
CaloCellClusterWeights.cxx:59
CaloCellClusterWeights::fastCheck
bool fastCheck(size_t hash) const
Fast checking if cell is used by any cluster.
Definition
CaloCellClusterWeights.cxx:36
CaloCellClusterWeights::weight_t
std::vector< double > weight_t
Type of weight.
Definition
CaloCellClusterWeights.h:28
CaloCellClusterWeights::m_defaultValue
weight_t m_defaultValue
Default (empty) entry.
Definition
CaloCellClusterWeights.h:141
CaloCellClusterWeights::~CaloCellClusterWeights
virtual ~CaloCellClusterWeights()
Destructor.
CaloCellClusterWeights::size
size_t size() const
Store size.
Definition
CaloCellClusterWeights.h:152
CaloCellClusterWeights::at
const weight_t & at(size_t hash) const
Accessing value using function and hash.
Definition
CaloCellClusterWeights.cxx:31
CaloCellClusterWeights::m_hashTable
store_t m_hashTable
Store implementation.
Definition
CaloCellClusterWeights.h:140
CaloCellClusterWeights::clear
void clear()
Clear the store.
Definition
CaloCellClusterWeights.cxx:55
CaloCellClusterWeights::set
void set(size_t hash, double value)
Definition
CaloCellClusterWeights.cxx:41
CaloCellClusterWeights::operator[]
const weight_t & operator[](size_t hash) const
Definition
CaloCellClusterWeights.cxx:29
CaloCell
Data object for each calorimeter readout cell.
Definition
CaloCell.h:57
CaloCell::caloDDE
const CaloDetDescrElement * caloDDE() const
get pointer to CaloDetDescrElement (data member)
Definition
CaloCell.h:321
CaloDetDescrElement::calo_hash
IdentifierHash calo_hash() const
cell calo hash
Definition
Calorimeter/CaloDetDescr/CaloDetDescr/CaloDetDescrElement.h:412
Generated on
for ATLAS Offline Software by
1.17.0