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())
25 std::pair<Coordinate,DetId> cur = fringe.back();
31 for (
auto direction : directions)
35 if ( neighbour.first < -halfWestEast ||
36 neighbour.first > halfWestEast ||
37 neighbour.second < -halfNorthSouth ||
38 neighbour.second > halfNorthSouth )
43 unsigned int_index = neighbour.first + halfWestEast +
44 eastWestSize * (neighbour.second + halfNorthSouth );
45 assert(int_index < visited_cells.size());
48 if (visited_cells[int_index].
visited)
54 visited_cells[int_index].visited =
true;
55 std::vector<DetId> neighbourCells =
getNeighbours(cur.second,direction);
57 if ( neighbourCells.size() == 1 )
58 visited_cells[int_index].cell = neighbourCells[0];
59 else if ( neighbourCells.empty() )
60 visited_cells[int_index].cell =
DetId(0);
62 throw cms::Exception(
"getWindowError") <<
"Not supported subdetector for getWindow method";
64 if (!visited_cells[int_index].cell.null())
65 fringe.emplace_back(std::pair<Coordinate,DetId>(neighbour,visited_cells[int_index].cell));
71 for (
auto & visited_cell : visited_cells)
72 if (!visited_cell.cell.null())
73 cellsInWindow.emplace_back(visited_cell.cell);
virtual std::vector< DetId > getNeighbours(const DetId &id, const CaloDirection &dir) const
std::pair< int, int > Coordinate
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.