ATLAS Offline Software
CaloClustersCopier.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3 */
5 
6 
7 #include "CaloClustersCopier.h"
8 
9 CaloClustersCopier::CaloClustersCopier(const std::string& name, ISvcLocator* pSvcLocator) :
10  AthReentrantAlgorithm(name, pSvcLocator)
11 {
12 }
13 
15 {
16 }
17 
19 {
20  ATH_CHECK(m_HIEventShapeKey.initialize());
23 
24  return StatusCode::SUCCESS;
25 }
26 
28 {
29  return StatusCode::SUCCESS;
30 }
31 
32 StatusCode CaloClustersCopier::execute(const EventContext& context) const
33 {
34 
35  auto esHandle = SG::makeHandle(m_HIEventShapeKey, context);
36  ATH_CHECK(esHandle.isValid());
37  auto inputClustersHandle = SG::makeHandle(m_inputClustersKey, context);
38  ATH_CHECK(inputClustersHandle.isValid());
39 
40  // construct and record output clusters in each event
41  auto outputClusters = std::make_unique<xAOD::CaloClusterContainer>();
42  auto outputClustersAux = std::make_unique<xAOD::CaloClusterAuxContainer>();
43  outputClusters->setStore(outputClustersAux.get());
44 
45  // calculate energy in fcal
46  double fcalEt = 0;
47 
48  for (const xAOD::HIEventShape* es : *esHandle) {
49  if (es->layer() == 21 || es->layer() == 22 || es->layer() == 23) { // Example: FCal layers
50  fcalEt += es->et();
51  }
52  }
53 
54  if ( fcalEt < m_fcalEtCut ) {
55  for ( auto inCluster: *inputClustersHandle ) {
56  xAOD::CaloCluster* outCluster = new xAOD::CaloCluster();
57  outputClusters->push_back(outCluster);
58  *outCluster = *inCluster;
59  }
60  }
61 
62  auto outputClustersHandle = SG::makeHandle(m_outputClustersKey, context);
63  ATH_CHECK( outputClustersHandle.record(std::move(outputClusters), std::move(outputClustersAux)) );
64 
65  return StatusCode::SUCCESS;
66 }
CaloClustersCopier::finalize
virtual StatusCode finalize() override
Definition: CaloClustersCopier.cxx:27
CaloClustersCopier::CaloClustersCopier
CaloClustersCopier(const std::string &name, ISvcLocator *pSvcLocator)
Definition: CaloClustersCopier.cxx:9
CaloClustersCopier::m_inputClustersKey
SG::ReadHandleKey< xAOD::CaloClusterContainer > m_inputClustersKey
Definition: CaloClustersCopier.h:32
CaloClustersCopier::initialize
virtual StatusCode initialize() override
Definition: CaloClustersCopier.cxx:18
CaloClustersCopier::m_fcalEtCut
Gaudi::Property< float > m_fcalEtCut
Definition: CaloClustersCopier.h:30
CaloClustersCopier::m_HIEventShapeKey
SG::ReadHandleKey< xAOD::HIEventShapeContainer > m_HIEventShapeKey
Definition: CaloClustersCopier.h:31
CaloClusterAuxContainer.h
xAOD::CaloCluster
CaloCluster_v1 CaloCluster
Define the latest version of the calorimeter cluster class.
Definition: Event/xAOD/xAODCaloEvent/xAODCaloEvent/CaloCluster.h:19
AthReentrantAlgorithm
An algorithm that can be simultaneously executed in multiple threads.
Definition: AthReentrantAlgorithm.h:74
SG::makeHandle
SG::ReadCondHandle< T > makeHandle(const SG::ReadCondHandleKey< T > &key, const EventContext &ctx=Gaudi::Hive::currentContext())
Definition: ReadCondHandle.h:274
xAOD::HIEventShape_v2
Interface class for the HI reconstruction EDM.
Definition: HIEventShape_v2.h:32
CaloClustersCopier.h
xAOD::CaloCluster_v1
Description of a calorimeter cluster.
Definition: CaloCluster_v1.h:62
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
SG::VarHandleKey::initialize
StatusCode initialize(bool used=true)
If this object is used as a property, then this should be called during the initialize phase.
Definition: AthToolSupport/AsgDataHandles/Root/VarHandleKey.cxx:103
CaloClustersCopier::m_outputClustersKey
SG::WriteHandleKey< xAOD::CaloClusterContainer > m_outputClustersKey
Definition: CaloClustersCopier.h:33
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:240
CaloClustersCopier::execute
virtual StatusCode execute(const EventContext &context) const override
Definition: CaloClustersCopier.cxx:32
CaloClustersCopier::~CaloClustersCopier
virtual ~CaloClustersCopier() override
Definition: CaloClustersCopier.cxx:14