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-2026 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 "
CaloTowerAlgorithm.h
"
13
14
#include <string>
15
#include <vector>
16
#include <iomanip>
17
18
CaloTowerAlgorithm::CaloTowerAlgorithm
(
const
std::string& name,
19
ISvcLocator* pSvcLocator)
20
:
AthReentrantAlgorithm
(name,pSvcLocator)
21
,
m_chrono
(
"ChronoStatSvc"
, name)
22
{
23
}
24
25
CaloTowerAlgorithm::~CaloTowerAlgorithm
()
26
=
default
;
27
29
// Initialize //
31
32
StatusCode
CaloTowerAlgorithm::initialize
()
33
{
34
// Retrieve ChronoStatSvc
35
if
(
m_doChronoStat
) {
36
ATH_CHECK
(
m_chrono
.retrieve() );
37
}
38
39
ATH_CHECK
(
m_towerContainerKey
.initialize());
41
// Allocate Tools //
43
44
// check tool names
45
if
(
m_ptools
.empty()) {
46
ATH_MSG_ERROR
(
" no tools given for this algorithm."
);
47
return
StatusCode::FAILURE;
48
}
49
50
// find tools
51
52
53
CaloTowerSeg
theTowerSeg(
m_nEtaTowers
,
m_nPhiTowers
,
m_minEta
,
m_maxEta
);
54
55
56
unsigned
int
toolCtr = 0;
57
ATH_MSG_INFO
(
" "
);
58
ATH_MSG_INFO
(
"List of tools in execution sequence:"
);
59
ATH_MSG_INFO
(
"------------------------------------"
);
60
61
ATH_CHECK
(
m_ptools
.retrieve());
62
63
for
(ToolHandle<ICaloTowerBuilderToolBase>& tool :
m_ptools
) {
64
toolCtr++;
65
66
ATH_MSG_INFO
(std::setw(2) << toolCtr <<
".) "
<< tool->type()
67
<<
"::name() = \042"
<< tool->name() <<
"\042"
);
68
69
ATH_MSG_INFO
(
"------------------------------------"
);
70
ATH_MSG_INFO
(
" "
);
71
72
ATH_MSG_DEBUG
(
" set correct tower seg for this tool "
73
<< tool->name());
74
75
tool->setTowerSeg(theTowerSeg);
76
77
// if (tool->initializeTool().isFailure()) {
78
// ATH_MSG_WARNING(" Tool failed to initialize");
79
// }
80
81
}
//close iteration over tools
82
return
StatusCode::SUCCESS;
83
}
84
86
// Execute //
88
89
StatusCode
CaloTowerAlgorithm::execute
(
const
EventContext& ctx)
const
90
{
91
93
// Tool Processing //
95
96
CaloTowerSeg
theTowerSeg(
m_nEtaTowers
,
m_nPhiTowers
,
m_minEta
,
m_maxEta
);
97
98
SG::WriteHandle<CaloTowerContainer>
theTowers(
m_towerContainerKey
, ctx);
99
ATH_CHECK
( theTowers.
record
(std::make_unique<CaloTowerContainer>(theTowerSeg)) );
100
101
102
ToolHandleArray<ICaloTowerBuilderToolBase>::const_iterator firstITool =
m_ptools
.begin();
103
ToolHandleArray<ICaloTowerBuilderToolBase>::const_iterator lastITool =
m_ptools
.end();
104
StatusCode processStatus = StatusCode::SUCCESS;
105
//
106
// loop stops only when Failure indicated by one of the tools
107
//
108
109
ATH_MSG_DEBUG
(
"In execute() "
);
110
111
while
(!processStatus.isFailure() && firstITool != lastITool) {
112
113
if
(
m_doChronoStat
) {
114
m_chrono
->chronoStart((*firstITool)->name());
115
}
116
117
processStatus = (*firstITool)->execute(ctx, theTowers.
ptr
());
118
119
if
(
m_doChronoStat
) {
120
m_chrono
->chronoStop((*firstITool)->name());
121
}
122
if
(!processStatus.isFailure()) {
123
ATH_MSG_DEBUG
((*firstITool)->name()
124
<<
": CaloTowerContainer::size() = "
<< theTowers->size());
125
126
++firstITool;
127
}
else
{
128
// some problem - but do not skip event loop!
129
ATH_MSG_ERROR
(
"problems while or after processing tool \042"
130
<< (*firstITool)->name()
131
<<
"\042 - cross-check CaloTowerContainer::size() = "
132
<< theTowers->size());
133
134
++firstITool;
135
}
136
}
137
138
return
StatusCode::SUCCESS;
139
}
140
142
// Finalize //
144
145
StatusCode
CaloTowerAlgorithm::finalize
()
146
{
147
return
StatusCode::SUCCESS;
148
}
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_INFO
#define ATH_MSG_INFO(x,...)
Definition
AthMsgStreamMacros.h:45
CaloTowerAlgorithm.h
CaloTowerSeg.h
errorcheck.h
Helpers for checking error return status codes and reporting errors.
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:76
CaloTowerAlgorithm::m_nEtaTowers
Gaudi::Property< unsigned int > m_nEtaTowers
Definition
CaloTowerAlgorithm.h:64
CaloTowerAlgorithm::m_chrono
ServiceHandle< IChronoStatSvc > m_chrono
Definition
CaloTowerAlgorithm.h:60
CaloTowerAlgorithm::finalize
virtual StatusCode finalize() override
Definition
CaloTowerAlgorithm.cxx:145
CaloTowerAlgorithm::m_doChronoStat
Gaudi::Property< bool > m_doChronoStat
Definition
CaloTowerAlgorithm.h:61
CaloTowerAlgorithm::m_nPhiTowers
Gaudi::Property< unsigned int > m_nPhiTowers
Definition
CaloTowerAlgorithm.h:65
CaloTowerAlgorithm::~CaloTowerAlgorithm
virtual ~CaloTowerAlgorithm()
CaloTowerAlgorithm::m_minEta
Gaudi::Property< double > m_minEta
Definition
CaloTowerAlgorithm.h:66
CaloTowerAlgorithm::initialize
virtual StatusCode initialize() override
inherited from Algorithm
Definition
CaloTowerAlgorithm.cxx:32
CaloTowerAlgorithm::m_ptools
ToolHandleArray< ICaloTowerBuilderToolBase > m_ptools
Definition
CaloTowerAlgorithm.h:74
CaloTowerAlgorithm::execute
virtual StatusCode execute(const EventContext &ctx) const override
Definition
CaloTowerAlgorithm.cxx:89
CaloTowerAlgorithm::m_maxEta
Gaudi::Property< double > m_maxEta
Definition
CaloTowerAlgorithm.h:67
CaloTowerAlgorithm::CaloTowerAlgorithm
CaloTowerAlgorithm(const std::string &name, ISvcLocator *pService)
Algorithm constructor.
Definition
CaloTowerAlgorithm.cxx:18
CaloTowerSeg
Data object stores CaloTower segmentation.
Definition
CaloTowerSeg.h:37
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