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-2023 CERN for the benefit of the ATLAS collaboration
3
*/
4
5
6
#include "
CaloEvent/CaloTowerSeg.h
"
7
#include "CaloEvent/CaloTowerContainer.h"
8
#include "
CaloEvent/CaloCellContainer.h
"
9
#include "CaloEvent/CaloClusterContainer.h"
10
#include "
CaloEvent/CaloTopoTowerContainer.h
"
11
#include "
CaloTopoTowerAlgorithm.h
"
12
13
#include <string>
14
#include <vector>
15
#include <iomanip>
16
17
CaloTopoTowerAlgorithm::CaloTopoTowerAlgorithm
(
const
std::string& name,
18
ISvcLocator* pSvcLocator)
19
:
AthReentrantAlgorithm
(name,pSvcLocator)
20
,
m_genericLink
(true)
21
,
m_ptools
( this )
22
,
m_cellContainerKey
(
"AllCalo"
)
23
,
m_clusterKey
(
"CaloTopoClusters"
)
24
,
m_cellToClusterMapKey
(
"CaloCell2TopoCluster"
)
25
,
m_towerContainerKey
(
"CmbTower"
)
26
,
m_newTowerContainerKey
(
"TopoTower"
)
27
,
m_caloSelection
(false)
28
{
29
// tool names
30
//declareProperty("TowerBuilderTools",m_toolNames);
31
declareProperty
(
"TowerBuilderTools"
,
m_ptools
);
32
// output data
33
//declareProperty("TowerContainerName",m_towerContainerName);
34
// linkable
35
declareProperty
(
"GenericLinked"
,
m_genericLink
);
36
38
//Item From CaloTopoTowerAlg
39
declareProperty
(
"Cell2ClusterMapName"
,
m_cellToClusterMapKey
);
40
declareProperty
(
"CellContainerName"
,
m_cellContainerKey
);
41
declareProperty
(
"ClusterContainerName"
,
m_clusterKey
);
42
declareProperty
(
"InputTowerContainerName"
,
m_towerContainerKey
);
43
declareProperty
(
"OutputTowerContainerName"
,
m_newTowerContainerKey
);
44
45
// Declare configurable properties of the algorithm
46
declareProperty
(
"MinimumCellEnergy"
,
m_minimumCellEnergy
= -1000000000.0);
47
declareProperty
(
"MinimumClusterEnergy"
,
m_minimumClusterEnergy
= -1000000000.0);
48
49
// Noise Tool stuff
50
declareProperty
(
"DefaultNoiseSigma"
,
m_noiseSigma
= 10.0);
51
declareProperty
(
"CellEnergySignificance"
,
m_cellESignificanceThreshold
= -1);
52
53
// Calo from which to use cells
54
declareProperty
(
"IncludedCalos"
,
m_includedCalos
);
55
declareProperty
(
"useCellWeight"
,
m_useCellWeights
=
true
);
56
57
//END Item From CaloTopoTowerAlg
59
60
}
61
62
CaloTopoTowerAlgorithm::~CaloTopoTowerAlgorithm
()
63
=
default
;
64
66
// Initialize //
68
69
StatusCode
CaloTopoTowerAlgorithm::initialize
()
70
{
71
ATH_CHECK
(
m_cellContainerKey
.initialize());
72
ATH_CHECK
(
m_clusterKey
.initialize());
73
ATH_CHECK
(
m_cellToClusterMapKey
.initialize());
74
ATH_CHECK
(
m_towerContainerKey
.initialize());
75
ATH_CHECK
(
m_newTowerContainerKey
.initialize());
76
77
m_caloIndices
.clear();
78
for
(
unsigned
int
iCalos=0; iCalos<
m_includedCalos
.size(); iCalos++ )
79
{
80
if
(
m_includedCalos
[iCalos] ==
"LAREM"
)
81
{
82
m_caloIndices
.push_back(
CaloCell_ID::LAREM
);
83
}
84
else
if
(
m_includedCalos
[iCalos] ==
"LARHEC"
)
85
{
86
m_caloIndices
.push_back(
CaloCell_ID::LARHEC
);
87
}
88
else
if
(
m_includedCalos
[iCalos] ==
"LARFCAL"
)
89
{
90
m_caloIndices
.push_back(
CaloCell_ID::LARFCAL
);
91
}
92
else
if
(
m_includedCalos
[iCalos] ==
"TILE"
)
93
{
94
m_caloIndices
.push_back(
CaloCell_ID::TILE
);
95
}
96
}
97
98
m_caloSelection
=
false
;
99
unsigned
int
nSubCalo=
static_cast<
int
>
(
CaloCell_ID::NSUBCALO
) ;
100
if
(!
m_caloIndices
.empty() &&
m_caloIndices
.size()<nSubCalo)
m_caloSelection
=
true
;
101
102
ATH_MSG_INFO
(
" Calo selection applied ? "
<<
m_caloSelection
);
103
if
(
m_caloSelection
) {
104
msg
() << MSG::INFO <<
" subcalo selected "
;
105
for
(
unsigned
int
iCalos=0;iCalos<
m_includedCalos
.size(); iCalos++ )
106
msg
() << MSG::INFO <<
" "
<<
m_includedCalos
[iCalos];
107
msg
() << MSG::INFO <<
" "
<<
endmsg
;
108
}
109
110
112
// Allocate Tools //
114
115
// check tool names
116
if
(
m_ptools
.empty() )
117
{
118
ATH_MSG_ERROR
(
"no tools given for this algorithm."
);
119
return
StatusCode::FAILURE;
120
}
121
122
// find tools
123
124
unsigned
int
toolCtr = 0;
125
ATH_MSG_INFO
(
" "
);
126
ATH_MSG_INFO
(
"List of tools in execution sequence:"
);
127
ATH_MSG_INFO
(
"------------------------------------"
);
128
129
StatusCode checkOut =
m_ptools
.retrieve();
130
if
( checkOut.isFailure() )
131
{
132
ATH_MSG_WARNING
(
"Cannot retrieve tool array "
<<
m_ptools
);
133
return
StatusCode::FAILURE;
134
}
135
136
for
(ToolHandle<ICaloTopoTowerBuilderToolBase>& tool :
m_ptools
)
137
{
138
toolCtr++;
139
/* ATH_MSG_INFO( "retrieving tool" );
140
141
if ( checkOut.isFailure() ) {
142
ATH_MSG_WARNING( "Cannot retrieve tool at ToolArray[" << toolCtr-1 << "]" );
143
ATH_MSG_WARNING( "This tool won't be used" );
144
}
145
else {
146
ATH_MSG_INFO( "retrieved tool" );
147
// print the list of tools
148
*/
149
150
151
ATH_MSG_INFO
( std::setw(2) << toolCtr <<
".) "
152
<< tool->type()
153
<<
"::name() = \042"
154
<< tool->name()
155
<<
"\042"
);
156
157
ATH_MSG_INFO
(
"------------------------------------"
);
158
ATH_MSG_INFO
(
" "
);
159
160
/*if ( tool->initializeTool().isFailure() ) {
161
162
ATH_MSG_WARNING( " Tool failed to initialize" );
163
}*/
164
165
}
//close iteration over tools
166
return
StatusCode::SUCCESS;
167
}
168
170
// Execute //
172
173
StatusCode
CaloTopoTowerAlgorithm::execute
(
const
EventContext& ctx)
const
174
{
175
177
// Re-allocate Services //
179
180
//timing
181
IChronoStatSvc* theTicker = chronoSvc();
182
184
// Tool Processing //
187
SG::ReadHandle<CaloTowerContainer>
towerContainer(
m_towerContainerKey
, ctx);
188
if
( !towerContainer.
isValid
() ) {
189
ATH_MSG_WARNING
(
" cannot retrieve tower container with key "
<< towerContainer.
name
() );
190
return
StatusCode::SUCCESS;
191
}
192
194
SG::ReadHandle<CaloCellContainer>
theCells(
m_cellContainerKey
, ctx);
195
if
( !theCells.
isValid
()) {
196
ATH_MSG_WARNING
(
" cannot retrieve cell container with key "
<< theCells.
name
() );
197
return
StatusCode::SUCCESS;
198
}
199
ATH_MSG_DEBUG
(
"CaloTopoTowerAlgorithm::execute "
<< theCells.
name
() <<
" size= "
<< theCells->size() );
200
202
SG::ReadHandle<CaloClusterContainer>
clusters(
m_clusterKey
, ctx);
203
204
if
( !clusters.isValid() )
205
{
206
ATH_MSG_WARNING
(
"cannot retrieve CaloClusterContainer with key <"
207
<< clusters.name() <<
">"
);
208
return
StatusCode::SUCCESS;
209
}
210
212
SG::ReadHandle<CaloCell2ClusterMap>
cellToClusterMap(
m_cellToClusterMapKey
, ctx);
213
if
( !cellToClusterMap.
isValid
() ){
214
ATH_MSG_WARNING
(
"cannot retrieve CaloCell2ClusterMap with key <"
215
<< cellToClusterMap.
name
() <<
">"
);
216
return
StatusCode::SUCCESS;
217
}
218
219
ATH_MSG_DEBUG
(
"Successfully retrieved CaloCell2ClusterMap <"
<< cellToClusterMap.
name
() <<
">"
);
220
221
SG::WriteHandle<CaloTopoTowerContainer>
theTowers(
m_newTowerContainerKey
, ctx);
222
ATH_CHECK
( theTowers.
record
(std::make_unique<CaloTopoTowerContainer>(towerContainer->towerseg())) );
223
225
//Starting to save variable to CaloTopoTowerContainer
226
//
227
228
theTowers->SetTowers(towerContainer.
cptr
());
229
theTowers->SetClusters(clusters.ptr());
230
theTowers->SetCells(theCells.
cptr
());
231
theTowers->SetCellToClusterMap(cellToClusterMap.
cptr
());
232
233
theTowers->SetMinimumCellEnergy(
m_minimumCellEnergy
);
234
theTowers->SetMinimumClusterEnergy(
m_minimumClusterEnergy
);
235
theTowers->SetUseCellWeights(
m_useCellWeights
);
236
237
// Noise tool stuff
238
theTowers->SetNoiseSigma(
m_noiseSigma
);
239
theTowers->SetCellESignificanceThreshold(
m_cellESignificanceThreshold
);
240
241
// List of calorimeters from which to use cells
242
theTowers->SetCaloIndices(
m_caloIndices
);
243
theTowers->SetCaloSelection(
m_caloSelection
);
244
245
//
246
//Finished saving variable to CaloTopoTowerContainer
248
249
ToolHandleArray<ICaloTopoTowerBuilderToolBase>::const_iterator firstITool =
m_ptools
.begin();
250
ToolHandleArray<ICaloTopoTowerBuilderToolBase>::const_iterator lastITool =
m_ptools
.end();
251
StatusCode processStatus = StatusCode::SUCCESS;
252
//
253
// loop stops only when Failure indicated by one of the tools
254
//
255
256
ATH_MSG_DEBUG
(
"In execute() "
);
257
258
while
( ! processStatus.isFailure() && firstITool != lastITool )
259
{
260
// CaloTopoTowerBuilderToolBase* pTool = *firstTool;
261
//sc = (*firstITool).retrieve();
262
//if ( sc.isFailure() ) { log << MSG::INFO << "error retrieving tool " << endmsg; }
263
264
//if ( (*firstITool).empty() ) { log << MSG::INFO << "tool is empty " << endmsg; }
265
266
//ATH_MSG_INFO( "tool retrieved, going to start " );
267
if
( theTicker !=
nullptr
)
268
{
269
// ATH_MSG_INFO( "Chrono start " );
270
theTicker->chronoStart((*firstITool)->name());
271
}
272
/* ATH_MSG_INFO( "executing tool: " << (*firstITool)->name() );
273
ATH_MSG_INFO( "this is &(firstITool): " << &(firstITool) );
274
ATH_MSG_INFO( "this is (*firstITool): " << (*firstITool) );
275
ATH_MSG_INFO( "this is &(*firstITool): " << &(*firstITool) );
276
ATH_MSG_INFO( "this is &(*(*firstITool)): " << &(*(*firstITool)) );
277
ATH_MSG_INFO( "this is theTowers: " << theTowers );
278
*/
279
280
processStatus = (*firstITool)->execute(ctx, theTowers.
ptr
());
281
282
// ATH_MSG_INFO( "processStatus is: " << processStatus );
283
284
285
if
( theTicker !=
nullptr
)
286
{
287
// ATH_MSG_INFO( "Chrono stop " );
288
theTicker->chronoStop((*firstITool)->name());
289
}
290
if
( ! processStatus.isFailure() )
291
{
292
ATH_MSG_DEBUG
( (*firstITool)->name()
293
<<
": CaloTopoTowerContainer::size() = "
294
<< theTowers->size() );
295
++firstITool;
296
}
297
else
298
{
299
// some problem - but do not skip event loop!
300
ATH_MSG_ERROR
(
"problems while or after processing tool \042"
301
<< (*firstITool)->name()
302
<<
"\042 - cross-check CaloTopoTowerContainer::size() = "
303
<< theTowers->size() );
304
++firstITool;
305
}
306
}
307
308
return
StatusCode::SUCCESS;
309
}
310
312
// Finalize //
314
315
StatusCode
CaloTopoTowerAlgorithm::finalize
()
316
{
317
return
StatusCode::SUCCESS;
318
}
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_ERROR
#define ATH_MSG_ERROR(x)
Definition
AthMsgStreamMacros.h:33
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition
AthMsgStreamMacros.h:31
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition
AthMsgStreamMacros.h:32
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition
AthMsgStreamMacros.h:29
CaloCellContainer.h
CaloTopoTowerAlgorithm.h
CaloTopoTowerContainer.h
CaloTowerSeg.h
AthCommonAlgorithm< Gaudi::Algorithm >::declareProperty
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)
Definition
AthCommonDataStore.h:145
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:80
CaloTopoTowerAlgorithm::m_minimumCellEnergy
double m_minimumCellEnergy
Definition
CaloTopoTowerAlgorithm.h:84
CaloTopoTowerAlgorithm::m_cellESignificanceThreshold
float m_cellESignificanceThreshold
Definition
CaloTopoTowerAlgorithm.h:90
CaloTopoTowerAlgorithm::m_useCellWeights
bool m_useCellWeights
Definition
CaloTopoTowerAlgorithm.h:86
CaloTopoTowerAlgorithm::initialize
virtual StatusCode initialize() override
inherited from Algorithm
Definition
CaloTopoTowerAlgorithm.cxx:69
CaloTopoTowerAlgorithm::m_noiseSigma
float m_noiseSigma
Definition
CaloTopoTowerAlgorithm.h:89
CaloTopoTowerAlgorithm::m_caloSelection
bool m_caloSelection
Definition
CaloTopoTowerAlgorithm.h:98
CaloTopoTowerAlgorithm::m_clusterKey
SG::ReadHandleKey< CaloClusterContainer > m_clusterKey
Definition
CaloTopoTowerAlgorithm.h:78
CaloTopoTowerAlgorithm::m_caloIndices
std::vector< CaloCell_ID::SUBCALO > m_caloIndices
Definition
CaloTopoTowerAlgorithm.h:97
CaloTopoTowerAlgorithm::m_cellContainerKey
SG::ReadHandleKey< CaloCellContainer > m_cellContainerKey
Definition
CaloTopoTowerAlgorithm.h:77
CaloTopoTowerAlgorithm::m_genericLink
bool m_genericLink
Definition
CaloTopoTowerAlgorithm.h:61
CaloTopoTowerAlgorithm::CaloTopoTowerAlgorithm
CaloTopoTowerAlgorithm(const std::string &name, ISvcLocator *pService)
Algorithm constructor.
Definition
CaloTopoTowerAlgorithm.cxx:17
CaloTopoTowerAlgorithm::execute
virtual StatusCode execute(const EventContext &ctx) const override
Definition
CaloTopoTowerAlgorithm.cxx:173
CaloTopoTowerAlgorithm::m_minimumClusterEnergy
double m_minimumClusterEnergy
Definition
CaloTopoTowerAlgorithm.h:85
CaloTopoTowerAlgorithm::m_ptools
ToolHandleArray< ICaloTopoTowerBuilderToolBase > m_ptools
Definition
CaloTopoTowerAlgorithm.h:65
CaloTopoTowerAlgorithm::m_cellToClusterMapKey
SG::ReadHandleKey< CaloCell2ClusterMap > m_cellToClusterMapKey
Definition
CaloTopoTowerAlgorithm.h:79
CaloTopoTowerAlgorithm::m_includedCalos
std::vector< std::string > m_includedCalos
Definition
CaloTopoTowerAlgorithm.h:96
CaloTopoTowerAlgorithm::m_newTowerContainerKey
SG::WriteHandleKey< CaloTopoTowerContainer > m_newTowerContainerKey
Definition
CaloTopoTowerAlgorithm.h:81
CaloTopoTowerAlgorithm::~CaloTopoTowerAlgorithm
virtual ~CaloTopoTowerAlgorithm()
CaloTopoTowerAlgorithm::finalize
virtual StatusCode finalize() override
Definition
CaloTopoTowerAlgorithm.cxx:315
SG::ReadHandle
Definition
StoreGate/StoreGate/ReadHandle.h:67
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:73
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