ATLAS Offline Software
Loading...
Searching...
No Matches
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
8
9CaloClustersCopier::CaloClustersCopier(const std::string& name, ISvcLocator* pSvcLocator) :
10 AthReentrantAlgorithm(name, pSvcLocator)
11{
12}
13
17
19{
20 ATH_CHECK(m_HIEventShapeKey.initialize());
21 ATH_CHECK(m_inputClustersKey.initialize());
22 ATH_CHECK(m_outputClustersKey.initialize());
23
24 return StatusCode::SUCCESS;
25}
26
28{
29 return StatusCode::SUCCESS;
30}
31
32StatusCode 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}
#define ATH_CHECK
Evaluate an expression and check for errors.
An algorithm that can be simultaneously executed in multiple threads.
CaloClustersCopier(const std::string &name, ISvcLocator *pSvcLocator)
virtual StatusCode initialize() override
SG::ReadHandleKey< xAOD::HIEventShapeContainer > m_HIEventShapeKey
virtual StatusCode execute(const EventContext &context) const override
Gaudi::Property< float > m_fcalEtCut
virtual StatusCode finalize() override
virtual ~CaloClustersCopier() override
SG::WriteHandleKey< xAOD::CaloClusterContainer > m_outputClustersKey
SG::ReadHandleKey< xAOD::CaloClusterContainer > m_inputClustersKey
SG::ReadCondHandle< T > makeHandle(const SG::ReadCondHandleKey< T > &key, const EventContext &ctx=Gaudi::Hive::currentContext())
CaloCluster_v1 CaloCluster
Define the latest version of the calorimeter cluster class.
HIEventShape_v2 HIEventShape
Definition of the latest event info version.