ATLAS Offline Software
Loading...
Searching...
No Matches
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//---------------
43
47
48#include "GaudiKernel/IChronoStatSvc.h"
49
51
52#include <memory> // for the std::unique_ptr
53#include <cmath>
54
55//###############################################################################
57 ISvcLocator* pSvcLocator)
58 : AthReentrantAlgorithm(name, pSvcLocator)
59 , m_towerOutput("")
61 , m_towerMakerTool(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
92= default;
93
94//###############################################################################
95
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"
103 } else {
104 ATH_MSG_DEBUG("Successfully retrieved tower maker tool "
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 "
112 } else {
113 ATH_MSG_DEBUG("Successfully retrieved tower correction tools "
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
147 return StatusCode::SUCCESS;
148}
149
150//###############################################################################
151
152StatusCode CaloTopoTowerMaker::execute (const EventContext& ctx) const
153{
154
155 // make a Cluster Container
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");
210 clusColl.ptr()));
211 return StatusCode::SUCCESS;
212}
213
214
216 return m_towerOutput.key();
217}
#define endmsg
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_ERROR(x)
#define ATH_MSG_DEBUG(x)
Helpers for checking error return status codes and reporting errors.
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)
const ServiceHandle< StoreGateSvc > & detStore() const
An algorithm that can be simultaneously executed in multiple threads.
static StatusCode AddContainerWriteHandle(SG::WriteHandle< xAOD::CaloClusterContainer > &clusColl)
Creates a new xAOD::CaloClusterContainer in the given WriteHandle + CaloClusterAuxContainer and recor...
static StatusCode finalizeClusters(SG::WriteHandle< CaloClusterCellLinkContainer > &h, xAOD::CaloClusterContainer *pClusterColl)
Finalize clusters (move CaloClusterCellLink to a separate container).
ToolHandle< CaloTowerCollectionProcessor > m_towerCalibratorTool
Tower calibrator(s)
virtual ~CaloTopoTowerMaker() override
SG::WriteHandleKey< xAOD::CaloClusterContainer > m_towerOutput
the name of the key in StoreGate for the output CaloClusterContainer
ToolHandle< CaloTowerCollectionProcessor > m_towerMakerTool
Tower makers.
const CaloCell_ID * m_caloCellID
Identifier helper.
bool m_useLCWCalibration
Use LCW calibration for topo-towers (default is true)
virtual StatusCode initialize() override
SG::WriteHandleKey< CaloClusterCellLinkContainer > m_towerCellLinkOutput
the name of the key in StoreGate for the output CaloClusterCellLinkContainer
const std::string & getOutputContainerName() const
CaloTopoTowerMaker(const std::string &name, ISvcLocator *pSvcLocator)
ToolHandleArray< CaloClusterCollectionProcessor > m_towerCorrectionTools
Tower (cluster) moment makers.
virtual StatusCode finalize() override
bool m_chronoTools
Use ChronotStatSvc to monitor each tool.
virtual StatusCode execute(const EventContext &ctx) const override
bool m_saveSignalState
Keep the individual results of each correction.
ServiceHandle< IChronoStatSvc > m_chrono
Handle to the ChronoStatSvc.
pointer_type ptr()
Dereference the pointer.
CaloCluster_v1 CaloCluster
Define the latest version of the calorimeter cluster class.