ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
Calorimeter
CaloRec
src
CaloTowerAlgorithm.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
// Gaudi includes
7
#include "GaudiKernel/IChronoStatSvc.h"
8
9
#include "
AthenaKernel/errorcheck.h
"
10
11
#include "
CaloEvent/CaloTowerSeg.h
"
12
#include "CaloEvent/CaloTowerContainer.h"
13
#include "
CaloTowerAlgorithm.h
"
14
15
#include <string>
16
#include <vector>
17
#include <iomanip>
18
19
CaloTowerAlgorithm::CaloTowerAlgorithm
(
const
std::string& name,
20
ISvcLocator* pSvcLocator)
21
:
AthReentrantAlgorithm
(name,pSvcLocator)
22
,
m_chrono
(
"ChronoStatSvc"
, name)
23
,
m_doChronoStat
(true)
24
,
m_nEtaTowers
(50)
25
,
m_nPhiTowers
(64)
26
,
m_minEta
(-2.5)
27
,
m_maxEta
(2.5)
28
,
m_genericLink
(true)
29
,
m_ptools
( this )
30
,
m_towerContainerKey
(
""
)
31
{
32
// chrono
33
declareProperty
(
"EnableChronoStat"
,
m_doChronoStat
);
34
// tool names
35
//declareProperty("TowerBuilderTools",m_toolNames);
36
declareProperty
(
"TowerBuilderTools"
,
m_ptools
);
37
// output data
38
declareProperty
(
"TowerContainerName"
,
m_towerContainerKey
);
39
// tower grid
40
declareProperty
(
"NumberOfEtaTowers"
,
m_nEtaTowers
);
41
declareProperty
(
"NumberOfPhiTowers"
,
m_nPhiTowers
);
42
declareProperty
(
"EtaMin"
,
m_minEta
);
43
declareProperty
(
"EtaMax"
,
m_maxEta
);
44
// linkable
45
declareProperty
(
"GenericLinked"
,
m_genericLink
);
46
}
47
48
CaloTowerAlgorithm::~CaloTowerAlgorithm
()
49
=
default
;
50
52
// Initialize //
54
55
StatusCode
CaloTowerAlgorithm::initialize
()
56
{
57
// Retrieve ChronoStatSvc
58
if
(
m_doChronoStat
) {
59
ATH_CHECK
(
m_chrono
.retrieve() );
60
}
61
62
ATH_CHECK
(
m_towerContainerKey
.initialize());
64
// Allocate Tools //
66
67
// check tool names
68
if
(
m_ptools
.empty()) {
69
ATH_MSG_ERROR
(
" no tools given for this algorithm."
);
70
return
StatusCode::FAILURE;
71
}
72
73
// find tools
74
75
76
CaloTowerSeg
theTowerSeg(
m_nEtaTowers
,
m_nPhiTowers
,
m_minEta
,
m_maxEta
);
77
78
79
unsigned
int
toolCtr = 0;
80
ATH_MSG_INFO
(
" "
);
81
ATH_MSG_INFO
(
"List of tools in execution sequence:"
);
82
ATH_MSG_INFO
(
"------------------------------------"
);
83
84
ATH_CHECK
(
m_ptools
.retrieve());
85
86
for
(ToolHandle<ICaloTowerBuilderToolBase>& tool :
m_ptools
) {
87
toolCtr++;
88
89
ATH_MSG_INFO
(std::setw(2) << toolCtr <<
".) "
<< tool->type()
90
<<
"::name() = \042"
<< tool->name() <<
"\042"
);
91
92
ATH_MSG_INFO
(
"------------------------------------"
);
93
ATH_MSG_INFO
(
" "
);
94
95
ATH_MSG_DEBUG
(
" set correct tower seg for this tool "
96
<< tool->name());
97
98
tool->setTowerSeg(theTowerSeg);
99
100
// if (tool->initializeTool().isFailure()) {
101
// ATH_MSG_WARNING(" Tool failed to initialize");
102
// }
103
104
}
//close iteration over tools
105
return
StatusCode::SUCCESS;
106
}
107
109
// Execute //
111
112
StatusCode
CaloTowerAlgorithm::execute
(
const
EventContext& ctx)
const
113
{
114
116
// Tool Processing //
118
119
CaloTowerSeg
theTowerSeg(
m_nEtaTowers
,
m_nPhiTowers
,
m_minEta
,
m_maxEta
);
120
121
SG::WriteHandle<CaloTowerContainer>
theTowers(
m_towerContainerKey
, ctx);
122
ATH_CHECK
( theTowers.
record
(std::make_unique<CaloTowerContainer>(theTowerSeg)) );
123
124
125
ToolHandleArray<ICaloTowerBuilderToolBase>::const_iterator firstITool =
m_ptools
.begin();
126
ToolHandleArray<ICaloTowerBuilderToolBase>::const_iterator lastITool =
m_ptools
.end();
127
StatusCode processStatus = StatusCode::SUCCESS;
128
//
129
// loop stops only when Failure indicated by one of the tools
130
//
131
132
ATH_MSG_DEBUG
(
"In execute() "
);
133
134
while
(!processStatus.isFailure() && firstITool != lastITool) {
135
136
if
(
m_doChronoStat
) {
137
m_chrono
->chronoStart((*firstITool)->name());
138
}
139
140
processStatus = (*firstITool)->execute(ctx, theTowers.
ptr
());
141
142
if
(
m_doChronoStat
) {
143
m_chrono
->chronoStop((*firstITool)->name());
144
}
145
if
(!processStatus.isFailure()) {
146
ATH_MSG_DEBUG
((*firstITool)->name()
147
<<
": CaloTowerContainer::size() = "
<< theTowers->size());
148
149
++firstITool;
150
}
else
{
151
// some problem - but do not skip event loop!
152
ATH_MSG_ERROR
(
"problems while or after processing tool \042"
153
<< (*firstITool)->name()
154
<<
"\042 - cross-check CaloTowerContainer::size() = "
155
<< theTowers->size());
156
157
++firstITool;
158
}
159
}
160
161
return
StatusCode::SUCCESS;
162
}
163
165
// Finalize //
167
168
StatusCode
CaloTowerAlgorithm::finalize
()
169
{
170
return
StatusCode::SUCCESS;
171
}
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_DEBUG
#define ATH_MSG_DEBUG(x)
Definition
AthMsgStreamMacros.h:29
CaloTowerAlgorithm.h
CaloTowerSeg.h
errorcheck.h
Helpers for checking error return status codes and reporting errors.
AthCommonAlgorithm< Gaudi::Algorithm >::declareProperty
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)
Definition
AthCommonDataStore.h:145
AthReentrantAlgorithm
An algorithm that can be simultaneously executed in multiple threads.
Definition
AthReentrantAlgorithm.h:74
CaloTowerAlgorithm::m_towerContainerKey
SG::WriteHandleKey< CaloTowerContainer > m_towerContainerKey
Definition
CaloTowerAlgorithm.h:74
CaloTowerAlgorithm::m_minEta
double m_minEta
Definition
CaloTowerAlgorithm.h:65
CaloTowerAlgorithm::m_chrono
ServiceHandle< IChronoStatSvc > m_chrono
Definition
CaloTowerAlgorithm.h:59
CaloTowerAlgorithm::finalize
virtual StatusCode finalize() override
Definition
CaloTowerAlgorithm.cxx:168
CaloTowerAlgorithm::m_nPhiTowers
unsigned int m_nPhiTowers
Definition
CaloTowerAlgorithm.h:64
CaloTowerAlgorithm::m_genericLink
bool m_genericLink
Definition
CaloTowerAlgorithm.h:68
CaloTowerAlgorithm::~CaloTowerAlgorithm
virtual ~CaloTowerAlgorithm()
CaloTowerAlgorithm::m_doChronoStat
bool m_doChronoStat
Definition
CaloTowerAlgorithm.h:60
CaloTowerAlgorithm::initialize
virtual StatusCode initialize() override
inherited from Algorithm
Definition
CaloTowerAlgorithm.cxx:55
CaloTowerAlgorithm::m_nEtaTowers
unsigned int m_nEtaTowers
Definition
CaloTowerAlgorithm.h:63
CaloTowerAlgorithm::m_ptools
ToolHandleArray< ICaloTowerBuilderToolBase > m_ptools
Definition
CaloTowerAlgorithm.h:72
CaloTowerAlgorithm::execute
virtual StatusCode execute(const EventContext &ctx) const override
Definition
CaloTowerAlgorithm.cxx:112
CaloTowerAlgorithm::m_maxEta
double m_maxEta
Definition
CaloTowerAlgorithm.h:65
CaloTowerAlgorithm::CaloTowerAlgorithm
CaloTowerAlgorithm(const std::string &name, ISvcLocator *pService)
Algorithm constructor.
Definition
CaloTowerAlgorithm.cxx:19
CaloTowerSeg
Data object stores CaloTower segmentation.
Definition
CaloTowerSeg.h:37
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