@@ -499,41 +499,44 @@ template <class InputType>
499499void 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 }
0 commit comments