Skip to content

Commit 7fc7fb7

Browse files
committed
further optimizations of EMCAL evalNExMax
1 parent d0ab2b9 commit 7fc7fb7

File tree

3 files changed

+21
-18
lines changed

3 files changed

+21
-18
lines changed

Detectors/EMCAL/base/include/EMCALBase/Geometry.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -435,7 +435,7 @@ class Geometry
435435
/// \param phiInModule index in phi direction in module
436436
/// \param etaInModule index in phi direction in module
437437
/// \return tuple with (row, column) of the cell, which is global numbering scheme
438-
std::tuple<int, int> GetTopologicalRowColumn(int supermoduleID, int moduleID, int phiInModule, int etaInModule) const;
438+
std::tuple<short, short> GetTopologicalRowColumn(int supermoduleID, int moduleID, int phiInModule, int etaInModule) const;
439439

440440
/// \brief Adapt cell indices in supermodule to online indexing
441441
/// \param supermoduleID super module number of the channel/cell

Detectors/EMCAL/base/src/ClusterFactory.cxx

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -499,41 +499,44 @@ template <class InputType>
499499
void ClusterFactory<InputType>::evalNExMax(gsl::span<const int> inputsIndices, AnalysisCluster& clusterAnalysis) const
500500
{
501501
// Pre-compute cell indices and energies for all cells in cluster to avoid multiple expensive geometry lookups
502-
struct CellInfo {
503-
int row;
504-
int column;
505-
double energy;
506-
};
507-
508-
std::vector<CellInfo> cellInfos;
509-
cellInfos.reserve(inputsIndices.size());
502+
const size_t n = inputsIndices.size();
503+
std::vector<short> rows;
504+
std::vector<short> columns;
505+
std::vector<double> energies;
506+
507+
rows.reserve(n);
508+
columns.reserve(n);
509+
energies.reserve(n);
510510

511511
for (auto iInput : inputsIndices) {
512512
auto [nSupMod, nModule, nIphi, nIeta] = mGeomPtr->GetCellIndex(mInputsContainer[iInput].getTower());
513513

514514
// get a nice topological indexing that is done in exactly the same way as used by the clusterizer
515515
// this way we can handle the shared cluster cases correctly
516-
auto [row, column] = mGeomPtr->GetTopologicalRowColumn(nSupMod, nModule, nIphi, nIeta);
517-
cellInfos.push_back({row, column, mInputsContainer[iInput].getEnergy()});
516+
const auto [row, column] = mGeomPtr->GetTopologicalRowColumn(nSupMod, nModule, nIphi, nIeta);
517+
518+
rows.push_back(row);
519+
columns.push_back(column);
520+
energies.push_back(mInputsContainer[iInput].getEnergy());
518521
}
519522

520523
// Now find local maxima using pre-computed data
521524
int nExMax = 0;
522-
for (size_t i = 0; i < cellInfos.size(); i++) {
525+
for (size_t i = 0; i < n; i++) {
523526
// this cell is assumed to be local maximum unless we find a higher energy cell in the neighborhood
524527
bool isExMax = true;
525528

526529
// loop over all other cells in cluster
527-
for (size_t j = 0; j < cellInfos.size(); j++) {
530+
for (size_t j = 0; j < n; j++) {
528531
if (i == j)
529532
continue;
530533

531534
// adjacent cell is any cell with adjacent phi or eta index
532-
if (std::abs(cellInfos[i].row - cellInfos[j].row) <= 1 &&
533-
std::abs(cellInfos[i].column - cellInfos[j].column) <= 1) {
535+
if (std::abs(rows[i] - rows[j]) <= 1 &&
536+
std::abs(columns[i] - columns[j]) <= 1) {
534537

535538
// if there is a cell with higher energy than the current cell, it is not a local maximum
536-
if (cellInfos[j].energy > cellInfos[i].energy) {
539+
if (energies[j] > energies[i]) {
537540
isExMax = false;
538541
break;
539542
}

Detectors/EMCAL/base/src/Geometry.cxx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1103,7 +1103,7 @@ std::tuple<int, int> Geometry::GetCellPhiEtaIndexInSModule(int supermoduleID, in
11031103
return std::make_tuple(phiInSupermodule, etaInSupermodule);
11041104
}
11051105

1106-
std::tuple<int, int> Geometry::GetTopologicalRowColumn(int supermoduleID, int moduleID, int phiInModule, int etaInModule) const
1106+
std::tuple<short, short> Geometry::GetTopologicalRowColumn(int supermoduleID, int moduleID, int phiInModule, int etaInModule) const
11071107
{
11081108
auto [iphi, ieta] = GetCellPhiEtaIndexInSModule(supermoduleID, moduleID, phiInModule, etaInModule);
11091109
int row = iphi;
@@ -1124,7 +1124,7 @@ std::tuple<int, int> Geometry::GetTopologicalRowColumn(int supermoduleID, int mo
11241124
column += supermoduleID % 2 * (48 + 1);
11251125
}
11261126

1127-
return std::make_tuple(row, column);
1127+
return std::make_tuple(static_cast<short>(row), static_cast<short>(column));
11281128
}
11291129

11301130
std::tuple<int, int> Geometry::ShiftOnlineToOfflineCellIndexes(Int_t supermoduleID, Int_t iphi, Int_t ieta) const

0 commit comments

Comments
 (0)