ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
Calorimeter
CaloRec
src
CaloTopoTowerAlgorithm.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 "
CaloEvent/CaloTowerSeg.h
"
7
#include "
CaloTopoTowerAlgorithm.h
"
8
9
#include <string>
10
#include <vector>
11
#include <iomanip>
12
13
CaloTopoTowerAlgorithm::CaloTopoTowerAlgorithm
(
const
std::string& name,
14
ISvcLocator* pSvcLocator)
15
:
AthReentrantAlgorithm
(name,pSvcLocator)
16
{
17
}
18
19
CaloTopoTowerAlgorithm::~CaloTopoTowerAlgorithm
()
20
=
default
;
21
23
// Initialize //
25
26
StatusCode
CaloTopoTowerAlgorithm::initialize
()
27
{
28
ATH_CHECK
(
m_cellContainerKey
.initialize());
29
ATH_CHECK
(
m_clusterKey
.initialize());
30
ATH_CHECK
(
m_cellToClusterMapKey
.initialize());
31
ATH_CHECK
(
m_towerContainerKey
.initialize());
32
ATH_CHECK
(
m_newTowerContainerKey
.initialize());
33
34
m_caloIndices
.clear();
35
for
(
unsigned
int
iCalos=0; iCalos<
m_includedCalos
.size(); iCalos++ )
36
{
37
if
(
m_includedCalos
[iCalos] ==
"LAREM"
)
38
{
39
m_caloIndices
.push_back(
CaloCell_ID::LAREM
);
40
}
41
else
if
(
m_includedCalos
[iCalos] ==
"LARHEC"
)
42
{
43
m_caloIndices
.push_back(
CaloCell_ID::LARHEC
);
44
}
45
else
if
(
m_includedCalos
[iCalos] ==
"LARFCAL"
)
46
{
47
m_caloIndices
.push_back(
CaloCell_ID::LARFCAL
);
48
}
49
else
if
(
m_includedCalos
[iCalos] ==
"TILE"
)
50
{
51
m_caloIndices
.push_back(
CaloCell_ID::TILE
);
52
}
53
}
54
55
m_caloSelection
=
false
;
56
unsigned
int
nSubCalo=
static_cast<
int
>
(
CaloCell_ID::NSUBCALO
) ;
57
if
(!
m_caloIndices
.empty() &&
m_caloIndices
.size()<nSubCalo)
m_caloSelection
=
true
;
58
59
ATH_MSG_INFO
(
" Calo selection applied ? "
<<
m_caloSelection
);
60
if
(
m_caloSelection
) {
61
msg
() << MSG::INFO <<
" subcalo selected "
;
62
for
(
unsigned
int
iCalos=0;iCalos<
m_includedCalos
.size(); iCalos++ )
63
msg
() << MSG::INFO <<
" "
<<
m_includedCalos
[iCalos];
64
msg
() << MSG::INFO <<
" "
<<
endmsg
;
65
}
66
67
69
// Allocate Tools //
71
72
// check tool names
73
if
(
m_ptools
.empty() )
74
{
75
ATH_MSG_ERROR
(
"no tools given for this algorithm."
);
76
return
StatusCode::FAILURE;
77
}
78
79
// find tools
80
81
unsigned
int
toolCtr = 0;
82
ATH_MSG_INFO
(
" "
);
83
ATH_MSG_INFO
(
"List of tools in execution sequence:"
);
84
ATH_MSG_INFO
(
"------------------------------------"
);
85
86
StatusCode checkOut =
m_ptools
.retrieve();
87
if
( checkOut.isFailure() )
88
{
89
ATH_MSG_WARNING
(
"Cannot retrieve tool array "
<<
m_ptools
);
90
return
StatusCode::FAILURE;
91
}
92
93
for
(ToolHandle<ICaloTopoTowerBuilderToolBase>& tool :
m_ptools
)
94
{
95
toolCtr++;
96
/* ATH_MSG_INFO( "retrieving tool" );
97
98
if ( checkOut.isFailure() ) {
99
ATH_MSG_WARNING( "Cannot retrieve tool at ToolArray[" << toolCtr-1 << "]" );
100
ATH_MSG_WARNING( "This tool won't be used" );
101
}
102
else {
103
ATH_MSG_INFO( "retrieved tool" );
104
// print the list of tools
105
*/
106
107
108
ATH_MSG_INFO
( std::setw(2) << toolCtr <<
".) "
109
<< tool->type()
110
<<
"::name() = \042"
111
<< tool->name()
112
<<
"\042"
);
113
114
ATH_MSG_INFO
(
"------------------------------------"
);
115
ATH_MSG_INFO
(
" "
);
116
117
/*if ( tool->initializeTool().isFailure() ) {
118
119
ATH_MSG_WARNING( " Tool failed to initialize" );
120
}*/
121
122
}
//close iteration over tools
123
return
StatusCode::SUCCESS;
124
}
125
127
// Execute //
129
130
StatusCode
CaloTopoTowerAlgorithm::execute
(
const
EventContext& ctx)
const
131
{
132
134
// Re-allocate Services //
136
137
//timing
138
IChronoStatSvc* theTicker = chronoSvc();
139
141
// Tool Processing //
144
SG::ReadHandle<CaloTowerContainer>
towerContainer(
m_towerContainerKey
, ctx);
145
if
( !towerContainer.
isValid
() ) {
146
ATH_MSG_WARNING
(
" cannot retrieve tower container with key "
<< towerContainer.
name
() );
147
return
StatusCode::SUCCESS;
148
}
149
151
SG::ReadHandle<CaloCellContainer>
theCells(
m_cellContainerKey
, ctx);
152
if
( !theCells.
isValid
()) {
153
ATH_MSG_WARNING
(
" cannot retrieve cell container with key "
<< theCells.
name
() );
154
return
StatusCode::SUCCESS;
155
}
156
ATH_MSG_DEBUG
(
"CaloTopoTowerAlgorithm::execute "
<< theCells.
name
() <<
" size= "
<< theCells->size() );
157
159
SG::ReadHandle<CaloClusterContainer>
clusters(
m_clusterKey
, ctx);
160
161
if
( !clusters.isValid() )
162
{
163
ATH_MSG_WARNING
(
"cannot retrieve CaloClusterContainer with key <"
164
<< clusters.name() <<
">"
);
165
return
StatusCode::SUCCESS;
166
}
167
169
SG::ReadHandle<CaloCell2ClusterMap>
cellToClusterMap(
m_cellToClusterMapKey
, ctx);
170
if
( !cellToClusterMap.
isValid
() ){
171
ATH_MSG_WARNING
(
"cannot retrieve CaloCell2ClusterMap with key <"
172
<< cellToClusterMap.
name
() <<
">"
);
173
return
StatusCode::SUCCESS;
174
}
175
176
ATH_MSG_DEBUG
(
"Successfully retrieved CaloCell2ClusterMap <"
<< cellToClusterMap.
name
() <<
">"
);
177
178
SG::WriteHandle<CaloTopoTowerContainer>
theTowers(
m_newTowerContainerKey
, ctx);
179
ATH_CHECK
( theTowers.
record
(std::make_unique<CaloTopoTowerContainer>(towerContainer->towerseg())) );
180
182
//Starting to save variable to CaloTopoTowerContainer
183
//
184
185
theTowers->SetTowers(towerContainer.
cptr
());
186
theTowers->SetClusters(clusters.ptr());
187
theTowers->SetCells(theCells.
cptr
());
188
theTowers->SetCellToClusterMap(cellToClusterMap.
cptr
());
189
190
theTowers->SetMinimumCellEnergy(
m_minimumCellEnergy
);
191
theTowers->SetMinimumClusterEnergy(
m_minimumClusterEnergy
);
192
theTowers->SetUseCellWeights(
m_useCellWeights
);
193
194
// Noise tool stuff
195
theTowers->SetNoiseSigma(
m_noiseSigma
);
196
theTowers->SetCellESignificanceThreshold(
m_cellESignificanceThreshold
);
197
198
// List of calorimeters from which to use cells
199
theTowers->SetCaloIndices(
m_caloIndices
);
200
theTowers->SetCaloSelection(
m_caloSelection
);
201
202
//
203
//Finished saving variable to CaloTopoTowerContainer
205
206
ToolHandleArray<ICaloTopoTowerBuilderToolBase>::const_iterator firstITool =
m_ptools
.begin();
207
ToolHandleArray<ICaloTopoTowerBuilderToolBase>::const_iterator lastITool =
m_ptools
.end();
208
StatusCode processStatus = StatusCode::SUCCESS;
209
//
210
// loop stops only when Failure indicated by one of the tools
211
//
212
213
ATH_MSG_DEBUG
(
"In execute() "
);
214
215
while
( ! processStatus.isFailure() && firstITool != lastITool )
216
{
217
// CaloTopoTowerBuilderToolBase* pTool = *firstTool;
218
//sc = (*firstITool).retrieve();
219
//if ( sc.isFailure() ) { log << MSG::INFO << "error retrieving tool " << endmsg; }
220
221
//if ( (*firstITool).empty() ) { log << MSG::INFO << "tool is empty " << endmsg; }
222
223
//ATH_MSG_INFO( "tool retrieved, going to start " );
224
if
( theTicker !=
nullptr
)
225
{
226
// ATH_MSG_INFO( "Chrono start " );
227
theTicker->chronoStart((*firstITool)->name());
228
}
229
/* ATH_MSG_INFO( "executing tool: " << (*firstITool)->name() );
230
ATH_MSG_INFO( "this is &(firstITool): " << &(firstITool) );
231
ATH_MSG_INFO( "this is (*firstITool): " << (*firstITool) );
232
ATH_MSG_INFO( "this is &(*firstITool): " << &(*firstITool) );
233
ATH_MSG_INFO( "this is &(*(*firstITool)): " << &(*(*firstITool)) );
234
ATH_MSG_INFO( "this is theTowers: " << theTowers );
235
*/
236
237
processStatus = (*firstITool)->execute(ctx, theTowers.
ptr
());
238
239
// ATH_MSG_INFO( "processStatus is: " << processStatus );
240
241
242
if
( theTicker !=
nullptr
)
243
{
244
// ATH_MSG_INFO( "Chrono stop " );
245
theTicker->chronoStop((*firstITool)->name());
246
}
247
if
( ! processStatus.isFailure() )
248
{
249
ATH_MSG_DEBUG
( (*firstITool)->name()
250
<<
": CaloTopoTowerContainer::size() = "
251
<< theTowers->size() );
252
++firstITool;
253
}
254
else
255
{
256
// some problem - but do not skip event loop!
257
ATH_MSG_ERROR
(
"problems while or after processing tool \042"
258
<< (*firstITool)->name()
259
<<
"\042 - cross-check CaloTopoTowerContainer::size() = "
260
<< theTowers->size() );
261
++firstITool;
262
}
263
}
264
265
return
StatusCode::SUCCESS;
266
}
267
269
// Finalize //
271
272
StatusCode
CaloTopoTowerAlgorithm::finalize
()
273
{
274
return
StatusCode::SUCCESS;
275
}
endmsg
#define endmsg
Definition
AnalysisConfig_Ntuple.cxx:54
ATH_CHECK
#define ATH_CHECK
Evaluate an expression and check for errors.
Definition
AthCheckMacros.h:40
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x,...)
Definition
AthMsgStreamMacros.h:43
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x,...)
Definition
AthMsgStreamMacros.h:47
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x,...)
Definition
AthMsgStreamMacros.h:46
ATH_MSG_INFO
#define ATH_MSG_INFO(x,...)
Definition
AthMsgStreamMacros.h:45
CaloTopoTowerAlgorithm.h
CaloTowerSeg.h
AthCommonAlgorithm< Gaudi::Algorithm >::msg
MsgStream & msg() const
Definition
AthCommonMsg.h:24
AthReentrantAlgorithm
An algorithm that can be simultaneously executed in multiple threads.
Definition
AthReentrantAlgorithm.h:74
CaloCell_Base_ID::LAREM
@ LAREM
Definition
CaloCell_Base_ID.h:45
CaloCell_Base_ID::TILE
@ TILE
Definition
CaloCell_Base_ID.h:45
CaloCell_Base_ID::LARFCAL
@ LARFCAL
Definition
CaloCell_Base_ID.h:45
CaloCell_Base_ID::LARHEC
@ LARHEC
Definition
CaloCell_Base_ID.h:45
CaloCell_Base_ID::NSUBCALO
@ NSUBCALO
Definition
CaloCell_Base_ID.h:45
CaloTopoTowerAlgorithm::m_towerContainerKey
SG::ReadHandleKey< CaloTowerContainer > m_towerContainerKey
Definition
CaloTopoTowerAlgorithm.h:85
CaloTopoTowerAlgorithm::m_includedCalos
Gaudi::Property< std::vector< std::string > > m_includedCalos
Definition
CaloTopoTowerAlgorithm.h:101
CaloTopoTowerAlgorithm::m_minimumCellEnergy
Gaudi::Property< double > m_minimumCellEnergy
Definition
CaloTopoTowerAlgorithm.h:89
CaloTopoTowerAlgorithm::initialize
virtual StatusCode initialize() override
inherited from Algorithm
Definition
CaloTopoTowerAlgorithm.cxx:26
CaloTopoTowerAlgorithm::m_useCellWeights
Gaudi::Property< bool > m_useCellWeights
Definition
CaloTopoTowerAlgorithm.h:91
CaloTopoTowerAlgorithm::m_minimumClusterEnergy
Gaudi::Property< double > m_minimumClusterEnergy
Definition
CaloTopoTowerAlgorithm.h:90
CaloTopoTowerAlgorithm::m_caloSelection
bool m_caloSelection
Definition
CaloTopoTowerAlgorithm.h:103
CaloTopoTowerAlgorithm::m_clusterKey
SG::ReadHandleKey< CaloClusterContainer > m_clusterKey
Definition
CaloTopoTowerAlgorithm.h:83
CaloTopoTowerAlgorithm::m_caloIndices
std::vector< CaloCell_ID::SUBCALO > m_caloIndices
Definition
CaloTopoTowerAlgorithm.h:102
CaloTopoTowerAlgorithm::m_cellContainerKey
SG::ReadHandleKey< CaloCellContainer > m_cellContainerKey
Definition
CaloTopoTowerAlgorithm.h:82
CaloTopoTowerAlgorithm::m_noiseSigma
Gaudi::Property< float > m_noiseSigma
Definition
CaloTopoTowerAlgorithm.h:94
CaloTopoTowerAlgorithm::CaloTopoTowerAlgorithm
CaloTopoTowerAlgorithm(const std::string &name, ISvcLocator *pService)
Algorithm constructor.
Definition
CaloTopoTowerAlgorithm.cxx:13
CaloTopoTowerAlgorithm::execute
virtual StatusCode execute(const EventContext &ctx) const override
Definition
CaloTopoTowerAlgorithm.cxx:130
CaloTopoTowerAlgorithm::m_ptools
ToolHandleArray< ICaloTopoTowerBuilderToolBase > m_ptools
Definition
CaloTopoTowerAlgorithm.h:70
CaloTopoTowerAlgorithm::m_cellToClusterMapKey
SG::ReadHandleKey< CaloCell2ClusterMap > m_cellToClusterMapKey
Definition
CaloTopoTowerAlgorithm.h:84
CaloTopoTowerAlgorithm::m_newTowerContainerKey
SG::WriteHandleKey< CaloTopoTowerContainer > m_newTowerContainerKey
Definition
CaloTopoTowerAlgorithm.h:86
CaloTopoTowerAlgorithm::~CaloTopoTowerAlgorithm
virtual ~CaloTopoTowerAlgorithm()
CaloTopoTowerAlgorithm::finalize
virtual StatusCode finalize() override
Definition
CaloTopoTowerAlgorithm.cxx:272
CaloTopoTowerAlgorithm::m_cellESignificanceThreshold
Gaudi::Property< float > m_cellESignificanceThreshold
Definition
CaloTopoTowerAlgorithm.h:95
SG::ReadHandle
Definition
StoreGate/StoreGate/ReadHandle.h:66
SG::ReadHandle::isValid
virtual bool isValid() override final
Can the handle be successfully dereferenced?
SG::ReadHandle::cptr
const_pointer_type cptr()
Dereference the pointer.
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::record
StatusCode record(std::unique_ptr< T > data)
Record a const object to the store.
SG::WriteHandle::ptr
pointer_type ptr()
Dereference the pointer.
Generated on
for ATLAS Offline Software by
1.17.0