ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
Calorimeter
CaloUtils
src
CaloClusterStoreHelper.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
#include "
CaloUtils/CaloClusterStoreHelper.h
"
6
#include "
CaloEvent/CaloClusterCellLink.h
"
7
#include "
xAODCaloEvent/CaloClusterAuxContainer.h
"
8
#include "
StoreGate/StoreGateSvc.h
"
9
#include "
SGTools/CurrentEventStore.h
"
10
#include "
AthenaKernel/errorcheck.h
"
11
12
13
std::unique_ptr<xAOD::CaloCluster>
CaloClusterStoreHelper::makeCluster
(
const
CaloCellContainer
* cellCont) {
14
return
makeCluster
(
DataLink<CaloCellContainer>
(cellCont));
15
}
16
17
18
std::unique_ptr<xAOD::CaloCluster>
CaloClusterStoreHelper::makeCluster
(
const
DataLink<CaloCellContainer>
& cellCont) {
19
std::unique_ptr<xAOD::CaloCluster> cluster = std::make_unique<xAOD::CaloCluster>();
20
cluster->makePrivateStore();
21
if
(cellCont) cluster->addCellLink(std::make_unique<CaloClusterCellLink>(cellCont));
22
return
cluster;
23
}
24
25
26
std::unique_ptr<xAOD::CaloCluster>
CaloClusterStoreHelper::makeCluster
(
const
CaloCellContainer
* cellCont,
27
const
double
eta0,
const
double
phi0,
28
const
xAOD::CaloCluster_v1::ClusterSize
clusterSize) {
29
std::unique_ptr<xAOD::CaloCluster> cluster=
CaloClusterStoreHelper::makeCluster
(cellCont);
30
cluster->setEta0(eta0);
31
cluster->setPhi0(phi0);
32
cluster->setClusterSize(clusterSize);
33
return
cluster;
34
}
35
36
37
xAOD::CaloCluster
*
CaloClusterStoreHelper::makeCluster
(
xAOD::CaloClusterContainer
* cont,
38
const
CaloCellContainer
* cellCont)
39
{
40
return
makeCluster
(cont,
DataLink<CaloCellContainer>
(cellCont));
41
}
42
43
44
xAOD::CaloCluster
*
CaloClusterStoreHelper::makeCluster
(
xAOD::CaloClusterContainer
* cont,
45
const
DataLink<CaloCellContainer>
& cellCont) {
46
47
xAOD::CaloCluster
* cluster=cont->
push_back
(std::make_unique<xAOD::CaloCluster>());
48
if
(cellCont) cluster->
addCellLink
(std::make_unique<CaloClusterCellLink>(cellCont));
49
return
cluster;
50
}
51
52
53
StatusCode
CaloClusterStoreHelper::AddContainerWriteHandle
(
SG::WriteHandle<xAOD::CaloClusterContainer>
&clusColl) {
54
55
// Create the xAOD container and its auxiliary store:
56
StatusCode
sc
=
57
clusColl.
record
(std::make_unique<xAOD::CaloClusterContainer>(),
58
std::make_unique<xAOD::CaloClusterAuxContainer>());
59
return
sc
;
60
}
61
62
63
StatusCode
64
CaloClusterStoreHelper::finalizeClusters
(
SG::WriteHandle<CaloClusterCellLinkContainer>
&
h
,
65
xAOD::CaloClusterContainer
* pClusterColl)
66
{
67
auto
cellLinks = std::make_unique<CaloClusterCellLinkContainer>();
68
69
//Loop on clusters and call setLink to transfer ownership of CaloClusterCellLink object to
70
//CaloClusterCellLinkContainer
71
IProxyDict
* sg = SG::CurrentEventStore::store();
72
for
(
xAOD::CaloCluster
* cl : *pClusterColl) {
73
cl->setLink(cellLinks.get(), sg);
74
}
75
76
return
h
.record (std::move (cellLinks));
77
}
78
79
void
80
CaloClusterStoreHelper::finalizeClusters
(
81
const
EventContext& ctx,
82
SG::WriteHandle<xAOD::CaloClusterContainer>
& outClusterContainer,
83
SG::WriteHandle<CaloClusterCellLinkContainer>
& outClusterContainerCellLink)
84
{
85
for
(
xAOD::CaloCluster
* cl : *outClusterContainer) {
86
cl->setLink(outClusterContainerCellLink.
ptr
(), ctx);
87
}
88
}
89
90
//Moved to here from CaloRunClusterCorrection
91
void
CaloClusterStoreHelper::copyContainer
(
const
xAOD::CaloClusterContainer
* oldColl,
xAOD::CaloClusterContainer
* newColl) {
92
// make a Cluster Container
93
newColl->
clear
();
94
newColl->
reserve
(oldColl->
size
());
95
for
(
const
xAOD::CaloCluster
* oldCluster : *oldColl) {
96
xAOD::CaloCluster
* newClu=newColl->
push_back
(std::make_unique<xAOD::CaloCluster>());
97
*newClu=*oldCluster;
98
//new xAOD::CaloCluster (*oldCluster)); //Copy c'tor creates a private AuxStore and a private ClusterCellLink obj
99
}
100
}
CaloClusterAuxContainer.h
CaloClusterCellLink.h
CaloClusterStoreHelper.h
errorcheck.h
Helpers for checking error return status codes and reporting errors.
sc
static Double_t sc
Definition
LArPhysWaveHECTool.cxx:37
CurrentEventStore.h
Hold a pointer to the current event store.
StoreGateSvc.h
h
Header file for AthHistogramAlgorithm.
CaloCellContainer
Container class for CaloCell.
Definition
CaloCellContainer.h:55
CaloClusterStoreHelper::makeCluster
static std::unique_ptr< xAOD::CaloCluster > makeCluster(const CaloCellContainer *cellCont)
Creates a valid CaloCluster with a private Aux-Store and CellLink container.
Definition
CaloClusterStoreHelper.cxx:13
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
DataLink
Object reference supporting deferred reading from StoreGate.
Definition
AthLinks/DataLink.h:93
DataVector::reserve
void reserve(size_type n)
Attempt to preallocate enough memory for a specified number of elements.
DataVector::push_back
value_type push_back(value_type pElem)
Add an element to the end of the collection.
DataVector::size
size_type size() const noexcept
Returns the number of elements in the collection.
DataVector::clear
void clear()
Erase all the elements in the collection.
IProxyDict
A proxy dictionary.
Definition
AthenaKernel/AthenaKernel/IProxyDict.h:47
SG::WriteHandle
Definition
StoreGate/StoreGate/WriteHandle.h:73
SG::WriteHandle::record
StatusCode record(std::unique_ptr< T > data)
Record a const object to the store.
SG::WriteHandle::ptr
pointer_type ptr()
Dereference the pointer.
xAOD::CaloCluster_v1::addCellLink
void addCellLink(CaloClusterCellLink *CCCL)
Definition
CaloCluster_v1.h:724
xAOD::CaloCluster_v1::ClusterSize
ClusterSize
Enumeration to identify different cluster sizes.
Definition
CaloCluster_v1.h:89
xAOD::CaloCluster
CaloCluster_v1 CaloCluster
Define the latest version of the calorimeter cluster class.
Definition
Event/xAOD/xAODCaloEvent/xAODCaloEvent/CaloCluster.h:19
xAOD::CaloClusterContainer
CaloClusterContainer_v1 CaloClusterContainer
Define the latest version of the calorimeter cluster container.
Definition
Event/xAOD/xAODCaloEvent/xAODCaloEvent/CaloClusterContainer.h:17
Generated on
for ATLAS Offline Software by
1.17.0