7 std::vector<DetId> cellsInWindow;
14 std::vector<std::pair<Coordinate,DetId> > fringe;
15 fringe.push_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.size() > 0)
25 std::pair<Coordinate,DetId> cur = fringe.back();
31 for (
unsigned dirnum = 0; dirnum < 4; ++dirnum)
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,directions[dirnum]);
57 if ( neighbourCells.size() == 1 )
58 visited_cells[int_index].cell = neighbourCells[0];
59 else if ( neighbourCells.size() == 0 )
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.push_back(std::pair<Coordinate,DetId>(neighbour,visited_cells[int_index].cell));
71 for (
unsigned int i=0;
i<visited_cells.size();
i++)
72 if (!visited_cells[
i].cell.null())
73 cellsInWindow.push_back(visited_cells[
i].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.