10 #include <unordered_map>
14 template <
typename cell_t>
16 std::unordered_map<
size_t, std::pair<cell_t, bool>>& cellMap,
size_t nBins0,
17 bool commonCorner,
double energyCut) {
19 std::vector<std::vector<cell_t>> mergedCells;
21 for (
auto& cell : cellMap) {
23 if (!(cell.second.second) &&
24 (cell.second.first.depositedEnergy() >= energyCut)) {
26 mergedCells.push_back(std::vector<cell_t>());
28 mergedCells.back().push_back(cell.second.first);
30 cell.second.second =
true;
32 fillCluster(mergedCells, cellMap, cell.first, nBins0, commonCorner,
40 template <
typename cell_t>
42 std::vector<std::vector<cell_t>>& mergedCells,
43 std::unordered_map<
size_t, std::pair<cell_t, bool>>& cellMap,
size_t index,
44 size_t nBins0,
bool commonCorner,
double energyCut) {
47 constexpr
int iMin = -1;
49 constexpr
int iMax = 1;
51 std::vector<int> neighbourIndices;
53 if ((index % nBins0) == 0) {
56 neighbourIndices = {jMin, jMin + iMax, iMax, jMax, jMax + iMax};
58 neighbourIndices = {jMin, iMax, jMax};
60 }
else if (((index + 1) % nBins0) == 0) {
63 neighbourIndices = {jMin + iMin, jMin, iMin, jMax + iMin, jMax};
65 neighbourIndices = {jMin, iMin, jMax};
69 neighbourIndices = {jMin + iMin, jMin, jMin + iMax, iMin,
70 iMax, jMax + iMin, jMax, jMax + iMax};
72 neighbourIndices = {jMin, iMin, iMax, jMax};
76 for (
auto& i : neighbourIndices) {
78 int neighbourIndex =
int(index) + i;
81 auto search = cellMap.find(neighbourIndex);
82 if ((search != cellMap.end())) {
84 auto newIndex = search->first;
85 auto currentCell = search->second.first;
88 if (!search->second.second &&
89 currentCell.depositedEnergy() >= energyCut) {
91 mergedCells.back().push_back(currentCell);
93 search->second.second =
true;
95 fillCluster(mergedCells, cellMap, newIndex, nBins0, commonCorner,