ATLAS Offline Software
Loading...
Searching...
No Matches
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
9
10CaloClusterTritonAlg::CaloClusterTritonAlg(const std::string &name, ISvcLocator *pSvcLocator)
11 : AthReentrantAlgorithm(name, pSvcLocator)
12{
13}
14
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());
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
34{
35 ATH_MSG_INFO("Finalizing " << name() << "...");
36 return StatusCode::SUCCESS;
37}
38
39StatusCode CaloClusterTritonAlg::execute(const EventContext &ctx) const
40{
41 ATH_MSG_DEBUG("Executing " << name() << "...");
42
44
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
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
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}
Scalar eta() const
pseudorapidity method
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_DEBUG(x,...)
#define ATH_MSG_ERROR(x,...)
#define ATH_MSG_INFO(x,...)
DataVector adapter that acts like it holds const pointers.
Handle class for reading from StoreGate.
Handle class for adding a decoration to an object.
An algorithm that can be simultaneously executed in multiple threads.
Gaudi::Property< std::vector< float > > m_rapidityRange
SG::WriteDecorHandleKey< xAOD::CaloClusterContainer > m_clusterGNNCalibEnergyDecorKey
CaloClusterTritonAlg(const std::string &name, ISvcLocator *pSvcLocator)
SG::ReadHandleKey< xAOD::CaloClusterContainer > m_clusterContainerKey
SG::ReadHandleKey< CaloCellContainer > m_cellContainerKey
StatusCode execute(const EventContext &ctx) const override
Gaudi::Property< double > m_minClusterEnergy
StatusCode finalize() override
StatusCode initialize() override
ToolHandle< ICaloClusterTritonTool > m_calibTool
DataVector adapter that acts like it holds const pointers.
value_type push_back(value_type pElem)
Add an element to the end of the collection.
const DV * asDataVector() const
Return a pointer to this object, as a const DataVector.
virtual bool isValid() override final
Can the handle be successfully dereferenced?
Handle class for adding a decoration to an object.
@ VIEW_ELEMENTS
this data object is a view, it does not own its elmts
CaloCluster_v1 CaloCluster
Define the latest version of the calorimeter cluster class.