ATLAS Offline Software
Loading...
Searching...
No Matches
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
10
12#include "CaloTowerAlgorithm.h"
13
14#include <string>
15#include <vector>
16#include <iomanip>
17
19 ISvcLocator* pSvcLocator)
20 : AthReentrantAlgorithm(name,pSvcLocator)
21 , m_chrono("ChronoStatSvc", name)
22{
23}
24
26= default;
27
29// Initialize //
31
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
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
89StatusCode CaloTowerAlgorithm::execute (const EventContext& ctx) const
90{
91
93 // Tool Processing //
95
97
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
146{
147 return StatusCode::SUCCESS;
148}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_DEBUG(x,...)
#define ATH_MSG_ERROR(x,...)
#define ATH_MSG_INFO(x,...)
Helpers for checking error return status codes and reporting errors.
An algorithm that can be simultaneously executed in multiple threads.
SG::WriteHandleKey< CaloTowerContainer > m_towerContainerKey
Gaudi::Property< unsigned int > m_nEtaTowers
ServiceHandle< IChronoStatSvc > m_chrono
virtual StatusCode finalize() override
Gaudi::Property< bool > m_doChronoStat
Gaudi::Property< unsigned int > m_nPhiTowers
virtual ~CaloTowerAlgorithm()
Gaudi::Property< double > m_minEta
virtual StatusCode initialize() override
inherited from Algorithm
ToolHandleArray< ICaloTowerBuilderToolBase > m_ptools
virtual StatusCode execute(const EventContext &ctx) const override
Gaudi::Property< double > m_maxEta
CaloTowerAlgorithm(const std::string &name, ISvcLocator *pService)
Algorithm constructor.
Data object stores CaloTower segmentation.
StatusCode record(std::unique_ptr< T > data)
Record a const object to the store.
pointer_type ptr()
Dereference the pointer.