29 std::vector<std::vector<GepCaloCell>> window(17, std::vector<GepCaloCell>(3));
35 unsigned int centerCellId = 0;
36 bool exactMatchFound =
false;
38 for (
auto it = cellMap->begin(); it != cellMap->end(); ++it) {
39 const auto& cell = it->second;
40 if (cell.sampling != 1)
continue;
43 if (cell.etaMin < seed.eta() && seed.eta() < cell.etaMax &&
44 cell.phiMin < seed.phi() && seed.phi() < cell.phiMax) {
46 centerCellId = cell.id;
47 exactMatchFound =
true;
53 if (!exactMatchFound || !centerCell) {
62 for (
int etaOffset = -8; etaOffset <= 8; etaOffset++) {
63 unsigned int windowRow = etaOffset + 8;
66 unsigned int baseId =
static_cast<unsigned int>(
static_cast<int>(centerCellId) + (etaOffset * 512));
69 for (
int phiOffset = -1; phiOffset <= 1; phiOffset++) {
70 int windowCol = phiOffset + 1;
73 unsigned int cellId =
static_cast<unsigned int>(
static_cast<int>(baseId) + phiOffset * 2);
76 auto it = cellMap->find(cellId);
77 if (it != cellMap->end()) {
78 const auto& cell = it->second;
79 if (cell.sampling == 1) {
80 window[windowRow][windowCol] = cell;
103 std::vector<LocalMax> localMaxima;
105 int rows = window.size();
106 int cols = window[0].size();
108 for (
int i = 0; i < rows; ++i) {
109 for (
int j = 0; j < cols; ++j) {
110 double current = window[i][j].e;
113 for (
int di = -1; di <= 1; ++di) {
114 for (
int dj = -1; dj <= 1; ++dj) {
115 if (di == 0 && dj == 0)
continue;
118 if (ni >= 0 && ni < rows && nj >= 0 && nj < cols) {
119 if (window[ni][nj].e >= current) {
128 if (isMax) localMaxima.push_back({current, i, j });
132 if (localMaxima.empty())
return {0., 0.};
135 std::sort(localMaxima.begin(), localMaxima.end(),
136 [](
const LocalMax&
a,
const LocalMax& b){ return a.energy > b.energy; });
138 double E1 = localMaxima[0].energy;
139 double E2 = (localMaxima.size() > 1) ? localMaxima[1].energy : 0.0;