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