ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
Calorimeter
CaloRec
src
CaloTopoTowerMaker.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
//-----------------------------------------------------------------------
7
// File and Version Information:
8
// $Id: CaloTopoTowerMaker.cxx,v 1.26 2009-04-18 02:56:18 ssnyder Exp $
9
//
10
// Description: see CaloTopoTowerMaker.h
11
//
12
// Environment:
13
// Software developed for the ATLAS Detector at CERN LHC
14
//
15
// Author List:
16
// Sven Menke
17
//
18
// Modified: Feb 09, 2005 (DLelas)
19
// - CaloTopoTowerMaker applies correction type tool on a whole
20
// cluster collection now. Needed for Sliding Window
21
// cell weights calculation.
22
//
23
// Modified Feb 2014 (W Lampl)
24
// - Migrate to xAOD::CaloCluster(Container)
25
// - Move to AthAlgorithm, some simplifications
26
//
27
// Modified Sep 2020 (T Chowdhury)
28
// -
29
//-----------------------------------------------------------------------
30
31
//-----------------------
32
// This Class's Header --
33
//-----------------------
34
#include "
CaloTopoTowerMaker.h
"
35
36
//---------------
37
// C++ Headers --
38
//---------------
39
#include "
xAODCaloEvent/CaloClusterContainer.h
"
40
#include "
xAODCaloEvent/CaloClusterAuxContainer.h
"
41
#include "
CaloEvent/CaloClusterCellLinkContainer.h
"
42
#include "
CaloEvent/CaloCellClusterWeights.h
"
43
44
#include "
CaloUtils/CaloClusterSignalState.h
"
45
#include "
CaloUtils/CaloClusterStoreHelper.h
"
46
#include "
AthenaKernel/errorcheck.h
"
47
48
#include "GaudiKernel/IChronoStatSvc.h"
49
50
#include "
CaloTopoClusterFromTowerHelpers.h
"
51
52
#include <memory>
// for the std::unique_ptr
53
#include <cmath>
54
55
//###############################################################################
56
CaloTopoTowerMaker::CaloTopoTowerMaker
(
const
std::string& name,
57
ISvcLocator* pSvcLocator)
58
:
AthReentrantAlgorithm
(name, pSvcLocator)
59
,
m_towerOutput
(
""
)
60
,
m_towerCellLinkOutput
(
""
)
61
,
m_towerMakerTool
(this)
62
,
m_towerCorrectionTools
(this)
63
,
m_towerCalibratorTool
(this)
64
,
m_chrono
(
"ChronoStatSvc"
, name)
65
{
66
// Name of Cluster Container to be registered in TDS
67
declareProperty
(
"TowersOutputName"
,
m_towerOutput
);
68
declareProperty
(
"TowerCellLinkOutputName"
,
m_towerCellLinkOutput
);
69
70
// Name(s) of Cluster Maker Tools
71
declareProperty
(
"TowerMakerTool"
,
m_towerMakerTool
);
72
73
// Name(s) of Cluster Correction Tools
74
declareProperty
(
"TowerCorrectionTools"
,
m_towerCorrectionTools
);
75
76
// Tower calibrator tool
77
declareProperty
(
"TowerCalibratorTool"
,
m_towerCalibratorTool
);
78
79
// save uncalibrated cluster signal state
80
declareProperty
(
"SaveUncalibratedSignalState"
,
m_saveSignalState
);
81
82
//Make Chrono Auditors for Cluster maker and correction tools
83
declareProperty
(
"ChronoTools"
,
m_chronoTools
);
84
85
// apply LCW calibration for towers
86
declareProperty
(
"UseLCWCalibration"
,
m_useLCWCalibration
);
87
}
88
89
//###############################################################################
90
91
CaloTopoTowerMaker::~CaloTopoTowerMaker
()
92
=
default
;
93
94
//###############################################################################
95
96
StatusCode
CaloTopoTowerMaker::initialize
()
97
{
98
99
// -- retrieve the needed tower maker tool
100
if
(
m_towerMakerTool
.retrieve().isFailure()) {
101
ATH_MSG_ERROR
(
"Failed to retrieve essential tower maker tool"
102
<<
m_towerMakerTool
);
103
}
else
{
104
ATH_MSG_DEBUG
(
"Successfully retrieved tower maker tool "
105
<<
m_towerMakerTool
);
106
}
107
108
// -- retrieve the (optional) list of correction tools
109
if
(
m_towerCorrectionTools
.retrieve().isFailure()) {
110
ATH_MSG_ERROR
(
"Failed to retrieve requested tower correction tools "
111
<<
m_towerCorrectionTools
);
112
}
else
{
113
ATH_MSG_DEBUG
(
"Successfully retrieved tower correction tools "
114
<<
m_towerCorrectionTools
);
115
}
116
117
// -- retrieve tower calibrator tool
118
if
(
m_useLCWCalibration
) {
119
if
(
m_towerCalibratorTool
.retrieve().isFailure() ) {
120
ATH_MSG_ERROR
(
"Failed to retrieve requested tower calibrator tool "
<<
m_towerCalibratorTool
);
121
}
else
{
122
ATH_MSG_DEBUG
(
"Sucessfully retrieved requested tower calibrator tool "
<<
m_towerCalibratorTool
);
123
}
124
}
125
126
if
(
m_chronoTools
) {
127
msg
(MSG::INFO) <<
"Will use ChronoStatSvc to monitor ClusterMaker and ClusterCorrection tools"
<<
endmsg
;
128
ATH_CHECK
(
m_chrono
.retrieve() );
129
}
130
131
ATH_CHECK
(
m_towerOutput
.initialize() );
132
133
if
(
m_towerCellLinkOutput
.key().empty()) {
134
m_towerCellLinkOutput
=
m_towerOutput
.key() +
"_links"
;
135
}
136
ATH_CHECK
(
m_towerCellLinkOutput
.initialize() );
137
138
139
ATH_CHECK
(
detStore
()->retrieve(
m_caloCellID
,
"CaloCell_ID"
));
140
141
return
StatusCode::SUCCESS;
142
}
143
144
//###############################################################################
145
146
StatusCode
CaloTopoTowerMaker::finalize
() {
147
return
StatusCode::SUCCESS;
148
}
149
150
//###############################################################################
151
152
StatusCode
CaloTopoTowerMaker::execute
(
const
EventContext& ctx)
const
153
{
154
155
// make a Cluster Container
156
SG::WriteHandle<xAOD::CaloClusterContainer>
clusColl (
m_towerOutput
, ctx);
157
ATH_CHECK
(
CaloClusterStoreHelper::AddContainerWriteHandle
(clusColl));
158
159
std::string chronoName(this->name()+std::string(
"_"
));
160
if
( !
m_useLCWCalibration
) {
161
// fill the towers without preparing for calibratoin
162
if
(
m_chronoTools
) {
m_chrono
->chronoStart(chronoName+
m_towerMakerTool
->name()); }
163
ATH_CHECK
(
m_towerMakerTool
->execute(ctx,clusColl.
ptr
(),
nullptr
) );
164
if
(
m_chronoTools
) {
m_chrono
->chronoStop(chronoName+
m_towerMakerTool
->name()); }
165
// save original signals bevore corrections and calibrations
166
if
(
m_saveSignalState
) {
167
for
(
xAOD::CaloCluster
* fClus : *clusColl) {
168
fClus->setRawE (fClus->e() );
169
fClus->setRawEta(fClus->eta());
170
fClus->setRawPhi(fClus->phi());
171
fClus->setRawM (fClus->m() );
172
}
//end loop over clusters
173
}
174
// apply the correction tools (really moment calculators)
175
for
(
auto
iter(
m_towerCorrectionTools
.begin()); iter !=
m_towerCorrectionTools
.end(); ++iter ) {
176
if
(
m_chronoTools
) {
m_chrono
->chronoStart(chronoName+iter->name()); }
177
ATH_CHECK
( (*iter)->execute(ctx,clusColl.
ptr
()) );
178
if
(
m_chronoTools
) {
m_chrono
->chronoStop(chronoName+iter->name()); }
179
}
// correction tool loop
180
}
else
{
181
// fill the towers with LCW calibration
182
std::unique_ptr<CaloCellClusterWeights> cellWeights=std::make_unique<CaloCellClusterWeights>(
m_caloCellID
->calo_cell_hash_max());
183
if
(
m_chronoTools
) {
m_chrono
->chronoStart(chronoName+
m_towerMakerTool
->name()); }
184
ATH_CHECK
(
m_towerMakerTool
->execute(ctx,clusColl.
ptr
(),cellWeights.get()) );
185
if
(
m_chronoTools
) {
m_chrono
->chronoStop(chronoName+
m_towerMakerTool
->name()); }
186
// save original signals bevore corrections and calibrations
187
if
(
m_saveSignalState
) {
188
for
(
xAOD::CaloCluster
* fClus : *clusColl) {
189
fClus->setRawE (fClus->e() );
190
fClus->setRawEta(fClus->eta());
191
fClus->setRawPhi(fClus->phi());
192
fClus->setRawM (fClus->m() );
193
}
//end loop over clusters
194
}
195
// apply the correction tools (really moment calculators)
196
for
(
auto
iter(
m_towerCorrectionTools
.begin()); iter !=
m_towerCorrectionTools
.end(); ++iter ) {
197
if
(
m_chronoTools
) {
m_chrono
->chronoStart(chronoName+iter->name()); }
198
ATH_CHECK
( (*iter)->execute(ctx,clusColl.
ptr
()) );
199
if
(
m_chronoTools
) {
m_chrono
->chronoStop(chronoName+iter->name()); }
200
}
// correction tool loop
201
// apply calibration
202
if
(
m_chronoTools
) {
m_chrono
->chronoStart(chronoName+
m_towerCalibratorTool
->name()); }
203
ATH_CHECK
(
m_towerCalibratorTool
->execute(ctx,clusColl.
ptr
(),cellWeights.get()) );
204
if
(
m_chronoTools
) {
m_chrono
->chronoStop(chronoName+
m_towerCalibratorTool
->name()); }
205
}
// end of processing blocks
206
207
ATH_MSG_DEBUG
(
"Created tower container (of type xAOD::CaloClusterContainer) with "
<< clusColl->size() <<
" towers"
);
208
SG::WriteHandle<CaloClusterCellLinkContainer>
cellLinks (
m_towerCellLinkOutput
, ctx);
209
ATH_CHECK
(
CaloClusterStoreHelper::finalizeClusters
(cellLinks,
210
clusColl.
ptr
()));
211
return
StatusCode::SUCCESS;
212
}
213
214
215
const
std::string&
CaloTopoTowerMaker::getOutputContainerName
()
const
{
216
return
m_towerOutput
.key();
217
}
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_DEBUG
#define ATH_MSG_DEBUG(x)
Definition
AthMsgStreamMacros.h:29
CaloCellClusterWeights.h
CaloClusterAuxContainer.h
CaloClusterCellLinkContainer.h
CaloClusterSignalState.h
CaloClusterStoreHelper.h
CaloTopoClusterFromTowerHelpers.h
CaloTopoTowerMaker.h
errorcheck.h
Helpers for checking error return status codes and reporting errors.
CaloClusterContainer.h
AthCommonAlgorithm< Gaudi::Algorithm >::declareProperty
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)
Definition
AthCommonDataStore.h:145
AthCommonAlgorithm< Gaudi::Algorithm >::detStore
const ServiceHandle< StoreGateSvc > & detStore() const
Definition
AthCommonDataStore.h:95
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
CaloClusterStoreHelper::AddContainerWriteHandle
static StatusCode AddContainerWriteHandle(SG::WriteHandle< xAOD::CaloClusterContainer > &clusColl)
Creates a new xAOD::CaloClusterContainer in the given WriteHandle + CaloClusterAuxContainer and recor...
Definition
CaloClusterStoreHelper.cxx:53
CaloClusterStoreHelper::finalizeClusters
static StatusCode finalizeClusters(SG::WriteHandle< CaloClusterCellLinkContainer > &h, xAOD::CaloClusterContainer *pClusterColl)
Finalize clusters (move CaloClusterCellLink to a separate container).
Definition
CaloClusterStoreHelper.cxx:64
CaloTopoTowerMaker::m_towerCalibratorTool
ToolHandle< CaloTowerCollectionProcessor > m_towerCalibratorTool
Tower calibrator(s).
Definition
CaloTopoTowerMaker.h:85
CaloTopoTowerMaker::~CaloTopoTowerMaker
virtual ~CaloTopoTowerMaker() override
CaloTopoTowerMaker::m_towerOutput
SG::WriteHandleKey< xAOD::CaloClusterContainer > m_towerOutput
the name of the key in StoreGate for the output CaloClusterContainer
Definition
CaloTopoTowerMaker.h:62
CaloTopoTowerMaker::m_towerMakerTool
ToolHandle< CaloTowerCollectionProcessor > m_towerMakerTool
Tower makers.
Definition
CaloTopoTowerMaker.h:73
CaloTopoTowerMaker::m_caloCellID
const CaloCell_ID * m_caloCellID
Identifier helper.
Definition
CaloTopoTowerMaker.h:111
CaloTopoTowerMaker::m_useLCWCalibration
bool m_useLCWCalibration
Use LCW calibration for topo-towers (default is true).
Definition
CaloTopoTowerMaker.h:107
CaloTopoTowerMaker::initialize
virtual StatusCode initialize() override
Definition
CaloTopoTowerMaker.cxx:96
CaloTopoTowerMaker::m_towerCellLinkOutput
SG::WriteHandleKey< CaloClusterCellLinkContainer > m_towerCellLinkOutput
the name of the key in StoreGate for the output CaloClusterCellLinkContainer
Definition
CaloTopoTowerMaker.h:66
CaloTopoTowerMaker::getOutputContainerName
const std::string & getOutputContainerName() const
Definition
CaloTopoTowerMaker.cxx:215
CaloTopoTowerMaker::CaloTopoTowerMaker
CaloTopoTowerMaker(const std::string &name, ISvcLocator *pSvcLocator)
Definition
CaloTopoTowerMaker.cxx:56
CaloTopoTowerMaker::m_towerCorrectionTools
ToolHandleArray< CaloClusterCollectionProcessor > m_towerCorrectionTools
Tower (cluster) moment makers.
Definition
CaloTopoTowerMaker.h:80
CaloTopoTowerMaker::finalize
virtual StatusCode finalize() override
Definition
CaloTopoTowerMaker.cxx:146
CaloTopoTowerMaker::m_chronoTools
bool m_chronoTools
Use ChronotStatSvc to monitor each tool.
Definition
CaloTopoTowerMaker.h:104
CaloTopoTowerMaker::execute
virtual StatusCode execute(const EventContext &ctx) const override
Definition
CaloTopoTowerMaker.cxx:152
CaloTopoTowerMaker::m_saveSignalState
bool m_saveSignalState
Keep the individual results of each correction.
Definition
CaloTopoTowerMaker.h:101
CaloTopoTowerMaker::m_chrono
ServiceHandle< IChronoStatSvc > m_chrono
Handle to the ChronoStatSvc.
Definition
CaloTopoTowerMaker.h:88
SG::WriteHandle
Definition
StoreGate/StoreGate/WriteHandle.h:73
SG::WriteHandle::ptr
pointer_type ptr()
Dereference the pointer.
xAOD::CaloCluster
CaloCluster_v1 CaloCluster
Define the latest version of the calorimeter cluster class.
Definition
Event/xAOD/xAODCaloEvent/xAODCaloEvent/CaloCluster.h:19
Generated on
for ATLAS Offline Software by
1.17.0