ATLAS Offline Software
Loading...
Searching...
No Matches
CaloClusterMaker.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3*/
4
5
6//-----------------------------------------------------------------------
7// File and Version Information:
8// $Id: CaloClusterMaker.cxx,v 1.26 2009-04-18 02:56:18 ssnyder Exp $
9//
10// Description: see CaloClusterMaker.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// - CaloClusterMaker 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
28//-----------------------
29// This Class's Header --
30//-----------------------
31#include "CaloClusterMaker.h"
32
33//---------------
34// C++ Headers --
35//---------------
39
43
44#include "GaudiKernel/IChronoStatSvc.h"
45
48
49//###############################################################################
50CaloClusterMaker::CaloClusterMaker(const std::string& name,
51 ISvcLocator* pSvcLocator)
52 : AthReentrantAlgorithm(name, pSvcLocator)
53 , m_clusterOutput("")
57 , m_chrono("ChronoStatSvc", name)
58 , m_saveSignalState(true)
59 , m_chronoTools(false)
60{
61
62 // Name of Cluster Container to be registered in TDS
63 declareProperty("ClustersOutputName",m_clusterOutput);
64 declareProperty("ClusterCellLinkOutputName",m_clusterCellLinkOutput);
65
66 // Name(s) of Cluster Maker Tools
67 declareProperty("ClusterMakerTools",m_clusterMakerTools);
68
69 // Name(s) of Cluster Correction Tools
70 declareProperty("ClusterCorrectionTools",m_clusterCorrectionTools);
71
72 // Name(s) of Cluster Correction Tools (even field) to trigger the
73 // recording of the current cluster container in StoreGate before
74 // its execution and the corresponding container name(s) (odd
75 // fields). This property and KeepEachCorrection are mutually
76 // exclusive
77 //declareProperty("KeepCorrectionToolAndContainerNames", m_keepCorrectionToolAndContainerNames);
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
86//###############################################################################
87
89= default;
90
91//###############################################################################
92
94{
95
96
97 if (m_clusterMakerTools.retrieve().isFailure()) {
98 ATH_MSG_ERROR("Failed to retrieve maker ToolHandleArray "
100 } else {
101 ATH_MSG_DEBUG("Successfully retrieved maker ToolHandleArray "
103 }
104
105 if (m_clusterCorrectionTools.retrieve().isFailure()) {
106 ATH_MSG_ERROR("Failed to retrieve correction ToolHandleArray "
108 } else {
109 ATH_MSG_DEBUG("Successfully retrieved correction ToolHandleArray "
111 }
112
113 if (m_chronoTools) {
114 msg(MSG::INFO) << "Will use ChronoStatSvc to monitor ClusterMaker and ClusterCorrection tools" << endmsg;
115 ATH_CHECK( m_chrono.retrieve() );
116 }
117
118 ATH_CHECK( m_clusterOutput.initialize() );
119
120 if (m_clusterCellLinkOutput.key().empty()) {
121 m_clusterCellLinkOutput = m_clusterOutput.key() + "_links";
122 }
123 ATH_CHECK( m_clusterCellLinkOutput.initialize() );
124
126 m_mDecor_ncells = m_clusterOutput.key() + "." + m_mDecor_ncells.key();
127 }
129
130 return StatusCode::SUCCESS;
131}
132
133//###############################################################################
134
136 return StatusCode::SUCCESS;
137}
138
139//###############################################################################
140
141StatusCode CaloClusterMaker::execute (const EventContext& ctx) const
142{
143
144 // make a Cluster Container
146
148 ATH_CHECK( clusColl.record(std::make_unique<xAOD::CaloClusterContainer>(),
149 std::make_unique<xAOD::CaloClusterTrigAuxContainer>()) );
150 }
151 else {
153 }
154
155 ToolHandleArray<CaloClusterCollectionProcessor>::const_iterator toolIt, toolIt_e; //Iterators over Tool handles
156 toolIt=m_clusterMakerTools.begin();
157 toolIt_e=m_clusterMakerTools.end();
158
159 //Make Clusters: Execute each maker tool
160 //for (CaloClusterCollectionProcessor& tool : m_clusterMakerTools) { //Doesn't work because CaloClusterCollectionProcessor is a base class
161 for(;toolIt!=toolIt_e;++toolIt) {
162 const std::string chronoName = this->name() + "_" +toolIt->name();
163 if (m_chronoTools) m_chrono->chronoStart(chronoName);
164 ATH_CHECK((*toolIt)->execute(ctx, clusColl.ptr()));
165 if (m_chronoTools) m_chrono->chronoStop(chronoName);
166 } //End loop over maker tools
167
168 // PL set calibrated state
169 if ( m_saveSignalState ) {
170 //Fixme: Maybe this loop would auto-vectorize breaking into four separate loops for each quantity
171 for (xAOD::CaloCluster* fClus : *clusColl) {
172 ATH_MSG_DEBUG( "found cluster with state "<< fClus->signalState());
173 fClus->setRawE(fClus->calE());
174 fClus->setRawEta(fClus->calEta());
175 fClus->setRawPhi(fClus->calPhi());
176 fClus->setRawM(fClus->calM());
177 }//end loop over clusters
178 }
179
180
181 //Apply corrections: Exectue each correction tool
182 //for (CaloClusterCollectionProcessor* tool : m_clusterCorrectionTools) { //Doesn't work because CaloClusterCollectionProcessor is a base class
183 toolIt=m_clusterCorrectionTools.begin();
184 toolIt_e=m_clusterCorrectionTools.end();
185 for(;toolIt!=toolIt_e;++toolIt) {
186 const std::string& toolname=(*toolIt).name();
187
188 ATH_MSG_DEBUG(" Applying correction = " << toolname);
189 const std::string chronoName = this->name() + "_" + toolname;
190 if (m_chronoTools) m_chrono->chronoStart(chronoName);
191 ATH_CHECK((*toolIt)->execute(ctx, clusColl.ptr()));
192 if (m_chronoTools) m_chrono->chronoStop(chronoName);
193 }//End loop over correction tools
194
197
198 for (const xAOD::CaloCluster * cl : *clusColl) {
199 const CaloClusterCellLink * cell_links = cl->getCellLinks();
200 if (!cell_links) {
201 decor_handle(*cl) = 0;
202 }
203 else {
204 decor_handle(*cl) = cell_links->size();
205 }
206 }
207 }
208
209 ATH_MSG_DEBUG("Created cluster container with " << clusColl->size() << " clusters");
212 clusColl.ptr()));
213
214 return StatusCode::SUCCESS;
215}
216
217
219 return m_clusterOutput.key();
220}
#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.
Handle class for adding a decoration to an object.
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)
An algorithm that can be simultaneously executed in multiple threads.
virtual StatusCode initialize() override
CaloClusterMaker(const std::string &name, ISvcLocator *pSvcLocator)
ToolHandleArray< CaloClusterCollectionProcessor > m_clusterCorrectionTools
the actual list of tools corresponding to above names
bool m_chronoTools
Use ChronotStatSvc to monitor each tool.
SG::WriteHandleKey< xAOD::CaloClusterContainer > m_clusterOutput
the name of the key in StoreGate for the output CaloClusterContainer
bool m_saveSignalState
controls saving the uncalibrated signal state just before the first CaloClusterCorrectionTool is invo...
ToolHandleArray< CaloClusterCollectionProcessor > m_clusterMakerTools
a list of names for tools to make clusters
virtual ~CaloClusterMaker() override
virtual StatusCode execute(const EventContext &ctx) const override
SG::WriteHandleKey< CaloClusterCellLinkContainer > m_clusterCellLinkOutput
the name of the key in StoreGate for the output CaloClusterCellLinkContainer
virtual StatusCode finalize() override
ServiceHandle< IChronoStatSvc > m_chrono
const std::string & getOutputContainerName() const
Gaudi::Property< bool > m_writeTriggerSpecificInfo
If true, writes some trigger-specific decorations.
SG::WriteDecorHandleKey< xAOD::CaloClusterContainer > m_mDecor_ncells
Key to the handle for writing the number of cells as a decoration.
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).
Handle class for adding a decoration to an object.
StatusCode record(std::unique_ptr< T > data)
Record a const object to the store.
pointer_type ptr()
Dereference the pointer.
CaloCluster_v1 CaloCluster
Define the latest version of the calorimeter cluster class.