ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
Calorimeter
CaloRec
src
CaloTowerxAODFromCells.cxx
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
3
*/
4
5
6
#include "
CaloTowerxAODFromCells.h
"
7
8
#include "
CaloEvent/CaloCell.h
"
9
10
11
#include "
xAODCaloEvent/CaloTowerContainer.h
"
12
#include "
xAODCaloEvent/CaloTowerAuxContainer.h
"
13
#include "
CaloGeoHelpers/CaloPhiRange.h
"
14
15
#include <limits>
16
17
CaloTowerxAODFromCells::CaloTowerxAODFromCells
(
const
std::string& name,ISvcLocator* pSvcLocator)
18
:
CaloTowerxAODAlgoBase
(name,pSvcLocator)
19
{
20
}
21
22
CaloTowerxAODFromCells::~CaloTowerxAODFromCells
()
23
=
default
;
24
25
StatusCode
CaloTowerxAODFromCells::initialize
() {
26
27
m_filterCells
=(
m_cellThresholdE
!=std::numeric_limits<float>::min());
28
ATH_CHECK
(
m_inputCellContainerKey
.initialize());
29
30
// process modes
31
if
(
m_filterCells
) {
32
ATH_MSG_INFO
(
"[Configuration::Status] FilterCell mode configured with Ecell > "
<<
m_cellThresholdE
<<
" MeV"
);
33
}
else
{
34
ATH_MSG_INFO
(
"[Configuration::Status] Using all cells"
);
35
}
36
37
return
initBase
();
38
}
39
40
StatusCode
CaloTowerxAODFromCells::execute
(
const
EventContext& ctx)
const
41
{
42
const
CellToTowerVec
& cellToTower =
getIndexCache
(ctx);
43
if
(cellToTower.empty()) {
44
ATH_MSG_ERROR
(
"Failed to compute the index cache"
);
45
return
StatusCode::FAILURE;
46
}
47
48
SG::ReadHandle<CaloCellContainer>
inputCellContainer(
m_inputCellContainerKey
, ctx);
49
if
(!inputCellContainer.
isValid
()) {
50
ATH_MSG_ERROR
(
"Can't retrieve CaloCellContainer with key "
<< inputCellContainer.
name
() );
51
return
StatusCode::FAILURE;
52
}
53
54
SG::WriteHandle<xAOD::CaloTowerContainer>
caloTowerContainer =
55
this->
makeContainer
(ctx);
56
if
(!caloTowerContainer.
isValid
())
57
return
StatusCode::FAILURE;
58
59
const
size_t
nCell2Tower=cellToTower.size();
60
if
(nCell2Tower<inputCellContainer->
size
()) {
61
ATH_MSG_ERROR
(
"Number of cells larger than size of internal cell2tower cache. nCells="
62
<< inputCellContainer->size() <<
", cell2tower size="
<< nCell2Tower );
63
return
StatusCode::FAILURE;
64
}
65
66
for
(
const
CaloCell
* cell : *inputCellContainer) {
67
68
if
(!
m_filterCells
|| (cell->e()>
m_cellThresholdE
)) {
69
70
const
IdentifierHash
cellHash=cell->caloDDE()->calo_hash();
71
assert(cellHash<cellToTower.size());
72
if
(!(cellHash<cellToTower.size())) {
73
ATH_MSG_ERROR
(
"Cell2Tower mapping too small "
<< cellToTower.size() <<
", expected at least"
<< cellHash );
74
return
StatusCode::FAILURE;
75
}
76
const
auto
& c2ts=cellToTower[cellHash];
77
//Remember: A cell can contribute to more than one tower!
78
for
(
const
cellToTower_t
& c2t : c2ts) {
79
if
(c2t.m_towerIdx > caloTowerContainer->size()) {
80
ATH_MSG_ERROR
(
"Tower container size too small "
<< caloTowerContainer->size() <<
", expected at least"
<< c2t.m_towerIdx );
81
return
StatusCode::FAILURE;
82
}
83
(*caloTowerContainer)[c2t.m_towerIdx]->addEnergy(cell->e()*c2t.m_weight);
84
}
//end loop over towers coverd by this cell
85
}
// end if filter cells
86
}
//end loop over cells
87
88
89
return
StatusCode::SUCCESS;
90
}
91
92
StatusCode
CaloTowerxAODFromCells::finalize
()
93
{
return
StatusCode::SUCCESS; }
94
95
96
97
98
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:47
ATH_MSG_INFO
#define ATH_MSG_INFO(x,...)
Definition
AthMsgStreamMacros.h:45
CaloCell.h
CaloPhiRange.h
CaloPhiRange class declaration.
CaloTowerAuxContainer.h
CaloTowerxAODFromCells.h
CaloTowerContainer.h
size
size_t size() const
Number of registered mappings.
CaloCell
Data object for each calorimeter readout cell.
Definition
CaloCell.h:57
CaloTowerxAODAlgoBase::initBase
StatusCode initBase()
<
Definition
CaloTowerxAODAlgoBase.cxx:23
CaloTowerxAODAlgoBase::CellToTowerVec
std::vector< std::vector< cellToTower_t > > CellToTowerVec
Definition
CaloTowerxAODAlgoBase.h:63
CaloTowerxAODAlgoBase::getIndexCache
const CellToTowerVec & getIndexCache(const EventContext &ctx) const
Definition
CaloTowerxAODAlgoBase.cxx:56
CaloTowerxAODAlgoBase::makeContainer
SG::WriteHandle< xAOD::CaloTowerContainer > makeContainer(const EventContext &ctx) const
Intialize m_cellToTower cache.
Definition
CaloTowerxAODAlgoBase.cxx:31
CaloTowerxAODAlgoBase::CaloTowerxAODAlgoBase
CaloTowerxAODAlgoBase(const std::string &name, ISvcLocator *pSvcLocator)
Default algorithm constructor.
Definition
CaloTowerxAODAlgoBase.cxx:15
CaloTowerxAODFromCells::execute
virtual StatusCode execute(const EventContext &ctx) const override
Execute algorithm.
Definition
CaloTowerxAODFromCells.cxx:40
CaloTowerxAODFromCells::initialize
virtual StatusCode initialize() override
Initialize algorithm.
Definition
CaloTowerxAODFromCells.cxx:25
CaloTowerxAODFromCells::m_cellThresholdE
Gaudi::Property< double > m_cellThresholdE
Cell energy threshold (only for FilteredCell mode).
Definition
CaloTowerxAODFromCells.h:47
CaloTowerxAODFromCells::CaloTowerxAODFromCells
CaloTowerxAODFromCells(const std::string &name, ISvcLocator *pSvcLocator)
Default algorithm constructor.
Definition
CaloTowerxAODFromCells.cxx:17
CaloTowerxAODFromCells::m_inputCellContainerKey
SG::ReadHandleKey< CaloCellContainer > m_inputCellContainerKey
Definition
CaloTowerxAODFromCells.h:46
CaloTowerxAODFromCells::m_filterCells
bool m_filterCells
Definition
CaloTowerxAODFromCells.h:50
CaloTowerxAODFromCells::finalize
virtual StatusCode finalize() override
Finalize algorithm.
Definition
CaloTowerxAODFromCells.cxx:92
CaloTowerxAODFromCells::~CaloTowerxAODFromCells
virtual ~CaloTowerxAODFromCells()
Baseclass destructor.
IdentifierHash
This is a "hash" representation of an Identifier.
Definition
IdentifierHash.h:25
SG::ReadHandle
Definition
StoreGate/StoreGate/ReadHandle.h:66
SG::ReadHandle::isValid
virtual bool isValid() override final
Can the handle be successfully dereferenced?
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:71
SG::WriteHandle::isValid
virtual bool isValid() override final
Can the handle be successfully dereferenced?
CaloTowerxAODAlgoBase::cellToTower_t
Definition
CaloTowerxAODAlgoBase.h:57
Generated on
for ATLAS Offline Software by
1.17.0