5 const int& northSouthSize,
6 const int& eastWestSize)
const {
7 std::vector<DetId> cellsInWindow;
14 std::vector<std::pair<Coordinate, DetId> > fringe;
15 fringe.emplace_back(std::pair<Coordinate, DetId>(
Coordinate(0, 0), myTmpId));
17 int halfWestEast = eastWestSize / 2;
18 int halfNorthSouth = northSouthSize / 2;
20 std::vector<CellInfo> visited_cells;
21 visited_cells.resize(northSouthSize * eastWestSize);
23 while (!fringe.empty()) {
24 std::pair<Coordinate, DetId> cur = fringe.back();
30 for (
auto direction : directions) {
33 if (neighbour.first < -halfWestEast || neighbour.first > halfWestEast || neighbour.second < -halfNorthSouth ||
34 neighbour.second > halfNorthSouth)
38 unsigned int_index = neighbour.first + halfWestEast + eastWestSize * (neighbour.second + halfNorthSouth);
39 assert(int_index < visited_cells.size());
42 if (visited_cells[int_index].
visited)
48 visited_cells[int_index].visited =
true;
49 std::vector<DetId> neighbourCells =
getNeighbours(cur.second, direction);
51 if (neighbourCells.size() == 1)
52 visited_cells[int_index].cell = neighbourCells[0];
53 else if (neighbourCells.empty())
54 visited_cells[int_index].cell =
DetId(0);
56 throw cms::Exception(
"getWindowError") <<
"Not supported subdetector for getWindow method";
58 if (!visited_cells[int_index].cell.null())
59 fringe.emplace_back(std::pair<Coordinate, DetId>(neighbour, visited_cells[int_index].cell));
64 for (
auto& visited_cell : visited_cells)
65 if (!visited_cell.cell.null())
66 cellsInWindow.emplace_back(visited_cell.cell);
virtual std::vector< DetId > getNeighbours(const DetId &id, const CaloDirection &dir) const
Coordinate getNeighbourIndex(const Coordinate &coord, const CaloDirection &dir) const
virtual std::vector< DetId > getWindow(const DetId &id, const int &northSouthSize, const int &eastWestSize) const
CaloDirection
Codes the local directions in the cell lattice.
std::pair< int, int > Coordinate