10#include "GaudiKernel/SystemOfUnits.h"
18 : base_class(
type, name, parent) {}
25 return StatusCode::SUCCESS;
30 std::size_t &nCells)
const
36 ATH_MSG_DEBUG(
"Cluster " << cluster.index() <<
" has no cell links.");
37 return StatusCode::SUCCESS;
41 if (!links->getCellContainer()) {
43 <<
" point to cell container '" << links->getCellContainerLink().dataID()
44 <<
"', which is not available in the event store.");
45 return StatusCode::FAILURE;
48 std::vector<int64_t> cellIds;
49 std::vector<float> cellEnergies;
50 cellIds.reserve(cluster.
size());
51 cellEnergies.reserve(cluster.
size());
57 const float cellE = cell->e() * itCell.weight() / Gaudi::Units::GeV;
60 cellIds.push_back(
static_cast<int64_t
>(cell->ID().get_identifier32().get_compact()));
61 cellEnergies.push_back(cellE);
64 nCells = cellIds.size();
65 const int64_t n =
static_cast<int64_t
>(nCells);
67 std::vector<float> globalFeatures{
static_cast<float>(cluster.
rawE() / Gaudi::Units::GeV)};
70 std::make_pair(std::vector<int64_t>{n, 1}, std::move(cellIds));
72 std::make_pair(std::vector<int64_t>{n, 1}, std::move(cellEnergies));
74 std::make_pair(std::vector<int64_t>{1}, std::move(globalFeatures));
76 return StatusCode::SUCCESS;
87 std::size_t nCells = 0;
89 if (nCells == 0)
return StatusCode::SUCCESS;
93 std::make_pair(std::vector<int64_t>{1, 1}, std::vector<float>{});
97 const auto itOut = outputData.find(
m_outputName.value());
98 if (itOut == outputData.end()) {
100 return StatusCode::FAILURE;
103 const auto &data = itOut->second.second;
104 if (
const auto *vf = std::get_if<std::vector<float>>(&data); vf && !vf->empty()) {
105 energyGeV = vf->front();
107 }
else if (
const auto *vi = std::get_if<std::vector<int64_t>>(&data); vi && !vi->empty()) {
108 energyGeV =
static_cast<double>(vi->front());
112 return StatusCode::SUCCESS;
116 std::vector<double> &clusterE_GNN_vec)
const
120 clusterE_GNN_vec.clear();
121 clusterE_GNN_vec.reserve(clusters.size());
123 std::size_t nFallback = 0;
126 const double rawE = cluster->rawE();
128 double energyGeV = 0.0;
132 if (valid && std::isfinite(energyGeV) && energyGeV > 0.0) {
133 clusterE_GNN_vec.push_back(energyGeV * Gaudi::Units::GeV);
135 clusterE_GNN_vec.push_back(rawE);
142 <<
" clusters fell back to raw energy (no cells above threshold or invalid prediction).");
145 return StatusCode::SUCCESS;
#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,...)
Data object for each calorimeter readout cell.
Bookkeeping of cells that make up a cluster Simplified replacement for CaloCellLink,...
const CaloClusterCellLink * getCellLinks() const
Get a pointer to the CaloClusterCellLink object (const version).
size_t size() const
size method (forwarded from CaloClusterCellLink obj)
const_cell_iterator cell_end() const
const_cell_iterator cell_begin() const
Iterator of the underlying CaloClusterCellLink (const version).
std::map< std::string, InferenceData > OutputDataMap
std::map< std::string, InferenceData > InputDataMap
CaloCluster_v1 CaloCluster
Define the latest version of the calorimeter cluster class.
CaloClusterContainer_v1 CaloClusterContainer
Define the latest version of the calorimeter cluster container.