ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
Calorimeter
CaloRec
src
CaloTowerxAODFromClusters.cxx
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3
*/
4
5
6
#include "
CaloTowerxAODFromClusters.h
"
7
8
9
#include "
xAODCaloEvent/CaloTowerContainer.h
"
10
#include "
xAODCaloEvent/CaloTowerAuxContainer.h
"
11
#include <memory>
12
13
#ifndef CALOTOWER_MAX_CELL_COUNT
14
#define CALOTOWER_MAX_CELL_COUNT 200000
15
#endif
16
17
18
CaloTowerxAODFromClusters::CaloTowerxAODFromClusters
(
const
std::string& name,ISvcLocator* pSvcLocator)
19
:
CaloTowerxAODAlgoBase
(name,pSvcLocator)
20
,
m_inputClusterContainerKey
(
"CaloCalTopoClusters"
)
21
{
22
declareProperty
(
"InputClusterContainer"
,
m_inputClusterContainerKey
);
23
}
24
25
CaloTowerxAODFromClusters::~CaloTowerxAODFromClusters
()
26
=
default
;
27
28
StatusCode
CaloTowerxAODFromClusters::initialize
() {
29
ATH_CHECK
(
m_inputClusterContainerKey
.initialize());
30
ATH_CHECK
(
initBase
() );
31
return
StatusCode::SUCCESS;
32
}
33
34
StatusCode
CaloTowerxAODFromClusters::execute
(
const
EventContext& ctx)
const
35
{
36
const
CellToTowerVec
& cellToTower =
getIndexCache
(ctx);
37
if
(cellToTower.empty()) {
38
ATH_MSG_ERROR
(
"Failed to compute the index cache"
);
39
return
StatusCode::FAILURE;
40
}
41
42
SG::ReadHandle<xAOD::CaloClusterContainer>
inputClusterContainer(
m_inputClusterContainerKey
, ctx);
43
44
SG::WriteHandle<xAOD::CaloTowerContainer>
caloTowerContainer =
45
this->
makeContainer
(ctx);
46
if
(!caloTowerContainer.
isValid
())
47
return
StatusCode::FAILURE;
48
49
auto
addedCellsMap = std::make_unique<std::bitset< CALOTOWER_MAX_CELL_COUNT> >();
50
51
for
(
const
xAOD::CaloCluster
* it_cluster : *inputClusterContainer) {
52
const
CaloClusterCellLink
* cellLinks=it_cluster->getCellLinks();
53
if
(!cellLinks) {
54
ATH_MSG_ERROR
(
"Cluster without cell links found in collection: "
<< inputClusterContainer.
name
());
55
return
StatusCode::FAILURE;
56
}
57
58
for
(
const
CaloCell
* cell : *cellLinks) {
59
//Ask cell for it's hash
60
const
IdentifierHash
cellHash = cell->caloDDE()->calo_hash();
61
//Check it this cell is already part of reducedCellContainer
62
if
(!addedCellsMap->test(cellHash)) {
63
addedCellsMap->set(cellHash);
64
assert(cellHash<cellToTower.size());
65
const
auto
& c2ts=cellToTower[cellHash];
66
//Remember: A cell can contribute to more than one tower!
67
for
(
const
cellToTower_t
& c2t : c2ts) {
68
(*caloTowerContainer)[c2t.m_towerIdx]->addEnergy(cell->e()*c2t.m_weight);
69
}
//end loop over towers coverd by this cell
70
}
//end cell has not been added yet
71
}
//end loop over cells in this cluster
72
}
//end loop over clusters
73
return
StatusCode::SUCCESS;
74
}
75
76
StatusCode
CaloTowerxAODFromClusters::finalize
()
77
{
return
StatusCode::SUCCESS; }
78
ATH_CHECK
#define ATH_CHECK
Evaluate an expression and check for errors.
Definition
AthCheckMacros.h:40
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition
AthMsgStreamMacros.h:32
CaloTowerAuxContainer.h
CaloTowerxAODFromClusters.h
CaloTowerContainer.h
AthCommonAlgorithm< Gaudi::Algorithm >::declareProperty
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)
Definition
AthCommonDataStore.h:145
CaloCell
Data object for each calorimeter readout cell.
Definition
CaloCell.h:57
CaloClusterCellLink
Bookkeeping of cells that make up a cluster Simplified replacement for CaloCellLink,...
Definition
CaloClusterCellLink.h:24
CaloTowerxAODAlgoBase::initBase
StatusCode initBase()
<
Definition
CaloTowerxAODAlgoBase.cxx:30
CaloTowerxAODAlgoBase::CellToTowerVec
std::vector< std::vector< cellToTower_t > > CellToTowerVec
Definition
CaloTowerxAODAlgoBase.h:62
CaloTowerxAODAlgoBase::getIndexCache
const CellToTowerVec & getIndexCache(const EventContext &ctx) const
Definition
CaloTowerxAODAlgoBase.cxx:63
CaloTowerxAODAlgoBase::makeContainer
SG::WriteHandle< xAOD::CaloTowerContainer > makeContainer(const EventContext &ctx) const
Intialize m_cellToTower cache.
Definition
CaloTowerxAODAlgoBase.cxx:38
CaloTowerxAODAlgoBase::CaloTowerxAODAlgoBase
CaloTowerxAODAlgoBase(const std::string &name, ISvcLocator *pSvcLocator)
Default algorithm constructor.
Definition
CaloTowerxAODAlgoBase.cxx:15
CaloTowerxAODFromClusters::~CaloTowerxAODFromClusters
virtual ~CaloTowerxAODFromClusters()
Baseclass destructor.
CaloTowerxAODFromClusters::initialize
virtual StatusCode initialize() override
Initialize algorithm.
Definition
CaloTowerxAODFromClusters.cxx:28
CaloTowerxAODFromClusters::execute
virtual StatusCode execute(const EventContext &) const override
Execute algorithm.
Definition
CaloTowerxAODFromClusters.cxx:34
CaloTowerxAODFromClusters::m_inputClusterContainerKey
SG::ReadHandleKey< xAOD::CaloClusterContainer > m_inputClusterContainerKey
Definition
CaloTowerxAODFromClusters.h:38
CaloTowerxAODFromClusters::CaloTowerxAODFromClusters
CaloTowerxAODFromClusters(const std::string &name, ISvcLocator *pSvcLocator)
Default algorithm constructor.
Definition
CaloTowerxAODFromClusters.cxx:18
CaloTowerxAODFromClusters::finalize
virtual StatusCode finalize() override
Finalize algorithm.
Definition
CaloTowerxAODFromClusters.cxx:76
IdentifierHash
This is a "hash" representation of an Identifier.
Definition
IdentifierHash.h:25
SG::ReadHandle
Definition
StoreGate/StoreGate/ReadHandle.h:67
SG::VarHandleBase::name
const std::string & name() const
Return the StoreGate ID for the referenced object.
Definition
AthToolSupport/AsgDataHandles/Root/VarHandleBase.cxx:75
SG::WriteHandle
Definition
StoreGate/StoreGate/WriteHandle.h:73
SG::WriteHandle::isValid
virtual bool isValid() override final
Can the handle be successfully dereferenced?
xAOD::CaloCluster
CaloCluster_v1 CaloCluster
Define the latest version of the calorimeter cluster class.
Definition
Event/xAOD/xAODCaloEvent/xAODCaloEvent/CaloCluster.h:19
CaloTowerxAODAlgoBase::cellToTower_t
Definition
CaloTowerxAODAlgoBase.h:56
Generated on
for ATLAS Offline Software by
1.17.0