ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
Calorimeter
CaloRec
src
CaloClusterSnapshot.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
#include "
CaloUtils/CaloClusterStoreHelper.h
"
6
7
#include "
CaloClusterSnapshot.h
"
8
#include "
AthenaKernel/errorcheck.h
"
9
#include "
CaloClusterMaker.h
"
10
11
// -------------------------------------------------------------
12
// Constructor
13
// -------------------------------------------------------------
14
CaloClusterSnapshot::CaloClusterSnapshot
(
const
std::string&
type
,
15
const
std::string& name,
16
const
IInterface* parent):
17
AthAlgTool
(
type
, name, parent),
18
m_outputKey
(
""
)
19
{
20
declareInterface<CaloClusterCollectionProcessor> (
this
);
21
declareProperty
(
"OutputName"
,
m_outputKey
);
22
declareProperty
(
"CellLinkName"
,
m_cellLinkOutputKey
);
23
declareProperty
(
"SetCrossLinks"
,
m_setCrossLinks
=
false
);
24
declareProperty
(
"FinalClusterContainerName"
,
m_finalContName
);
25
26
}
27
28
// -------------------------------------------------------------
29
// Destructor
30
// -------------------------------------------------------------
31
CaloClusterSnapshot::~CaloClusterSnapshot
()
32
=
default
;
33
34
StatusCode
CaloClusterSnapshot::initialize
() {
35
ATH_CHECK
(
m_outputKey
.initialize());
36
if
(
m_cellLinkOutputKey
.key().empty()) {
37
m_cellLinkOutputKey
=
m_outputKey
.key() +
"_links"
;
38
}
39
ATH_CHECK
(
m_cellLinkOutputKey
.initialize());
40
return
StatusCode::SUCCESS;
41
42
}
43
44
45
StatusCode
46
CaloClusterSnapshot::execute
(
const
EventContext& ctx,
47
xAOD::CaloClusterContainer
* clusColl)
const
48
{
49
ATH_MSG_DEBUG
(
"Executing CaloClusterSnapshot"
);
50
51
SG::WriteHandle<xAOD::CaloClusterContainer>
outputColl(
m_outputKey
, ctx);
52
53
ATH_CHECK
(
CaloClusterStoreHelper::AddContainerWriteHandle
(outputColl));
54
55
CaloClusterStoreHelper::copyContainer
(clusColl,outputColl.
ptr
());
56
57
if
(
m_setCrossLinks
) {
58
const
size_t
nClusters=clusColl->
size
();
59
if
(nClusters!=outputColl->size()) {
60
ATH_MSG_ERROR
(
"After copy of container: Unequal number of entries! Original "
<< nClusters <<
", copy "
<< outputColl->size());
61
return
StatusCode::FAILURE;
62
}
63
64
//final cluster to snapshot:
65
using
ClusterLink_t
=
ElementLink<xAOD::CaloClusterContainer>
;
66
ClusterLink_t
outputEL (outputColl.
name
(), 0, ctx);
67
for
(
size_t
i=0;i<nClusters;++i) {
68
(*clusColl)[i]->setSisterClusterLink(
ClusterLink_t
(outputEL, i));
69
}
70
71
//From snapshot to final cluster
72
if
(
m_setCrossLinks
) {
73
ClusterLink_t
finalEL (
m_finalContName
, 0, ctx);
74
if
(finalEL.
isValid
()) {
75
for
(
size_t
i=0;i<nClusters;++i) {
76
(*outputColl)[i]->setSisterClusterLink(
ClusterLink_t
(finalEL, i));
77
// std::cout << "Setting link to " << m_finalContName << ", index "<< i <<std::endl;
78
}
79
}
80
else
{
81
ATH_MSG_DEBUG
(
"Can't set element link from snapshot to final cluster, likely mismatch in the FinalClusterContainerName"
);
82
}
83
}
84
}
85
86
87
SG::WriteHandle<CaloClusterCellLinkContainer>
cellLinks (
m_cellLinkOutputKey
, ctx);
88
ATH_CHECK
(
CaloClusterStoreHelper::finalizeClusters
(cellLinks,
89
outputColl.
ptr
()));
90
91
return
StatusCode::SUCCESS;
92
}
93
ATH_CHECK
#define ATH_CHECK
Evaluate an expression and check for errors.
Definition
AthCheckMacros.h:40
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x,...)
Definition
AthMsgStreamMacros.h:43
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x,...)
Definition
AthMsgStreamMacros.h:47
CaloClusterMaker.h
CaloClusterSnapshot.h
CaloClusterStoreHelper.h
errorcheck.h
Helpers for checking error return status codes and reporting errors.
AthAlgTool::AthAlgTool
AthAlgTool(const std::string &type, const std::string &name, const IInterface *parent)
Constructor with parameters:
Definition
AthAlgTool.cxx:16
AthCommonDataStore< AthCommonMsg< AlgTool > >::declareProperty
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)
Definition
AthCommonDataStore.h:145
CaloClusterSnapshot::execute
virtual StatusCode execute(const EventContext &ctx, xAOD::CaloClusterContainer *) const override
Execute on an entire collection of clusters.
Definition
CaloClusterSnapshot.cxx:46
CaloClusterSnapshot::m_cellLinkOutputKey
SG::WriteHandleKey< CaloClusterCellLinkContainer > m_cellLinkOutputKey
Definition
CaloClusterSnapshot.h:30
CaloClusterSnapshot::~CaloClusterSnapshot
virtual ~CaloClusterSnapshot() override
CaloClusterSnapshot::m_setCrossLinks
bool m_setCrossLinks
Definition
CaloClusterSnapshot.h:32
CaloClusterSnapshot::initialize
virtual StatusCode initialize() override
Definition
CaloClusterSnapshot.cxx:34
CaloClusterSnapshot::CaloClusterSnapshot
CaloClusterSnapshot(const std::string &type, const std::string &name, const IInterface *parent)
Definition
CaloClusterSnapshot.cxx:14
CaloClusterSnapshot::m_finalContName
std::string m_finalContName
Definition
CaloClusterSnapshot.h:34
CaloClusterSnapshot::m_outputKey
SG::WriteHandleKey< xAOD::CaloClusterContainer > m_outputKey
Definition
CaloClusterSnapshot.h:29
CaloClusterStoreHelper::copyContainer
static void copyContainer(const xAOD::CaloClusterContainer *oldColl, xAOD::CaloClusterContainer *newColl)
Deep copy of a cluster container.
Definition
CaloClusterStoreHelper.cxx:91
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
DataVector::size
size_type size() const noexcept
Returns the number of elements in the collection.
ElementLink
ElementLink implementation for ROOT usage.
Definition
A/AthLinks/ElementLink.h:40
ElementLink::isValid
bool isValid() const
Check if the element can be found.
SG::VarHandleBase::name
const std::string & name() const
Return the StoreGate ID for the referenced object.
Definition
AthToolSupport/AsgDataHandles/Root/VarHandleBase.cxx:75
SG::WriteHandle
Definition
StoreGate/StoreGate/WriteHandle.h:73
SG::WriteHandle::ptr
pointer_type ptr()
Dereference the pointer.
ClusterLink_t
ElementLink< xAOD::CaloClusterContainer > ClusterLink_t
Definition
egammaTruthAssociationAlg.cxx:53
xAOD::CaloClusterContainer
CaloClusterContainer_v1 CaloClusterContainer
Define the latest version of the calorimeter cluster container.
Definition
Event/xAOD/xAODCaloEvent/xAODCaloEvent/CaloClusterContainer.h:17
type
Generated on
for ATLAS Offline Software by
1.17.0