ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
Calorimeter
CaloRec
src
CaloClusterTritonAlg.cxx
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
3
*/
4
5
#include "
CaloClusterTritonAlg.h
"
6
#include "
StoreGate/ReadHandle.h
"
7
#include "
StoreGate/WriteDecorHandle.h
"
8
#include "
AthContainers/ConstDataVector.h
"
9
10
CaloClusterTritonAlg::CaloClusterTritonAlg
(
const
std::string &name, ISvcLocator *pSvcLocator)
11
:
AthReentrantAlgorithm
(name, pSvcLocator)
12
{
13
}
14
15
StatusCode
CaloClusterTritonAlg::initialize
()
16
{
17
ATH_MSG_INFO
(
"Initializing "
<< name() <<
"..."
);
18
19
ATH_CHECK
(
m_calibTool
.retrieve());
20
ATH_CHECK
(
m_clusterContainerKey
.initialize());
21
ATH_CHECK
(
m_cellContainerKey
.initialize());
22
ATH_CHECK
(
m_clusterGNNCalibEnergyDecorKey
.initialize());
23
24
if
(
m_rapidityRange
.size() == 2) {
25
ATH_MSG_INFO
(
"GNN calibration will be applied for clusters within ["
26
<<
m_rapidityRange
[0] <<
","
<<
m_rapidityRange
[1] <<
"]"
);
27
}
28
ATH_MSG_INFO
(
"GNN calibration will be applied to clusters with energy >= "
<<
m_minClusterEnergy
<<
" MeV"
);
29
30
return
StatusCode::SUCCESS;
31
}
32
33
StatusCode
CaloClusterTritonAlg::finalize
()
34
{
35
ATH_MSG_INFO
(
"Finalizing "
<< name() <<
"..."
);
36
return
StatusCode::SUCCESS;
37
}
38
39
StatusCode
CaloClusterTritonAlg::execute
(
const
EventContext &ctx)
const
40
{
41
ATH_MSG_DEBUG
(
"Executing "
<< name() <<
"..."
);
42
43
SG::WriteDecorHandle<xAOD::CaloClusterContainer, double>
clusterGNNCalibEnergyDecor(
m_clusterGNNCalibEnergyDecorKey
, ctx);
44
45
SG::ReadHandle<xAOD::CaloClusterContainer>
clusterReadHandle(
m_clusterContainerKey
, ctx);
46
if
(!clusterReadHandle.
isValid
())
47
{
48
ATH_MSG_ERROR
(
"cannot allocate the input cluster container with key <"
<<
m_clusterContainerKey
.key() <<
">"
);
49
return
StatusCode::FAILURE;
50
}
51
52
SG::ReadHandle<CaloCellContainer>
cellReadHandle(
m_cellContainerKey
, ctx);
53
if
(!cellReadHandle.
isValid
())
54
{
55
ATH_MSG_ERROR
(
"cannot retrieve the cell container with key <"
<<
m_cellContainerKey
.key()
56
<<
">; the GNN needs the cells referenced by the cluster cell links"
);
57
return
StatusCode::FAILURE;
58
}
59
60
// only run inference for clusters passing cuts
61
ConstDataVector<xAOD::CaloClusterContainer>
selectedClusters(
SG::VIEW_ELEMENTS
);
62
std::vector<bool> clusterMask(clusterReadHandle->size(),
false
);
63
for
(
const
xAOD::CaloCluster
*cluster : *clusterReadHandle) {
64
if
(
m_rapidityRange
.size() == 2) {
65
const
double
eta
= cluster->eta(
xAOD::CaloCluster::UNCALIBRATED
);
66
if
(
eta
<
m_rapidityRange
[0] ||
eta
>
m_rapidityRange
[1])
continue
;
67
}
68
// minimum cluster energy cut; in MeV
69
if
(cluster->rawE() <
m_minClusterEnergy
)
continue
;
70
71
selectedClusters.
push_back
(cluster);
72
clusterMask.at(cluster->index()) =
true
;
73
}
74
75
std::vector<double> clusterE_GNN_vec;
76
ATH_CHECK
(
m_calibTool
->inference(*selectedClusters.
asDataVector
(), clusterE_GNN_vec));
77
78
if
(clusterE_GNN_vec.size() != selectedClusters.size()) {
79
ATH_MSG_ERROR
(
"Tool returned "
<< clusterE_GNN_vec.size() <<
" energies for "
80
<< selectedClusters.size() <<
" selected clusters"
);
81
return
StatusCode::FAILURE;
82
}
83
84
size_t
i = 0;
85
for
(
const
xAOD::CaloCluster
*cluster : *clusterReadHandle)
86
{
87
if
(clusterMask.at(cluster->index())) {
88
clusterGNNCalibEnergyDecor(*cluster) = clusterE_GNN_vec[i];
89
++i;
90
}
else
{
91
clusterGNNCalibEnergyDecor(*cluster) = cluster->rawE();
92
}
93
}
94
95
return
StatusCode::SUCCESS;
96
}
eta
Scalar eta() const
pseudorapidity method
Definition
AmgMatrixBasePlugin.h:83
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
ATH_MSG_INFO
#define ATH_MSG_INFO(x,...)
Definition
AthMsgStreamMacros.h:45
CaloClusterTritonAlg.h
ConstDataVector.h
DataVector adapter that acts like it holds const pointers.
ReadHandle.h
Handle class for reading from StoreGate.
WriteDecorHandle.h
Handle class for adding a decoration to an object.
AthReentrantAlgorithm
An algorithm that can be simultaneously executed in multiple threads.
Definition
AthReentrantAlgorithm.h:74
CaloClusterTritonAlg::m_rapidityRange
Gaudi::Property< std::vector< float > > m_rapidityRange
Definition
CaloClusterTritonAlg.h:51
CaloClusterTritonAlg::m_clusterGNNCalibEnergyDecorKey
SG::WriteDecorHandleKey< xAOD::CaloClusterContainer > m_clusterGNNCalibEnergyDecorKey
Definition
CaloClusterTritonAlg.h:47
CaloClusterTritonAlg::CaloClusterTritonAlg
CaloClusterTritonAlg(const std::string &name, ISvcLocator *pSvcLocator)
Definition
CaloClusterTritonAlg.cxx:10
CaloClusterTritonAlg::m_clusterContainerKey
SG::ReadHandleKey< xAOD::CaloClusterContainer > m_clusterContainerKey
Definition
CaloClusterTritonAlg.h:39
CaloClusterTritonAlg::m_cellContainerKey
SG::ReadHandleKey< CaloCellContainer > m_cellContainerKey
Definition
CaloClusterTritonAlg.h:44
CaloClusterTritonAlg::execute
StatusCode execute(const EventContext &ctx) const override
Definition
CaloClusterTritonAlg.cxx:39
CaloClusterTritonAlg::m_minClusterEnergy
Gaudi::Property< double > m_minClusterEnergy
Definition
CaloClusterTritonAlg.h:55
CaloClusterTritonAlg::finalize
StatusCode finalize() override
Definition
CaloClusterTritonAlg.cxx:33
CaloClusterTritonAlg::initialize
StatusCode initialize() override
Definition
CaloClusterTritonAlg.cxx:15
CaloClusterTritonAlg::m_calibTool
ToolHandle< ICaloClusterTritonTool > m_calibTool
Definition
CaloClusterTritonAlg.h:36
ConstDataVector
DataVector adapter that acts like it holds const pointers.
Definition
ConstDataVector.h:76
ConstDataVector::push_back
value_type push_back(value_type pElem)
Add an element to the end of the collection.
ConstDataVector::asDataVector
const DV * asDataVector() const
Return a pointer to this object, as a const DataVector.
SG::ReadHandle
Definition
StoreGate/StoreGate/ReadHandle.h:66
SG::ReadHandle::isValid
virtual bool isValid() override final
Can the handle be successfully dereferenced?
SG::WriteDecorHandle
Handle class for adding a decoration to an object.
Definition
StoreGate/StoreGate/WriteDecorHandle.h:100
xAOD::CaloCluster_v1::UNCALIBRATED
@ UNCALIBRATED
Definition
CaloCluster_v1.h:313
SG::VIEW_ELEMENTS
@ VIEW_ELEMENTS
this data object is a view, it does not own its elmts
Definition
OwnershipPolicy.h:18
xAOD::CaloCluster
CaloCluster_v1 CaloCluster
Define the latest version of the calorimeter cluster class.
Definition
Event/xAOD/xAODCaloEvent/xAODCaloEvent/CaloCluster.h:19
Generated on
for ATLAS Offline Software by
1.17.0