CMS 3D CMS Logo

CaloSubdetectorTopology.h
Go to the documentation of this file.
1 #ifndef TOPOLOGY_CALOTOPOLOGY_CALOSUBDETECTORTOPOLOGY_H
2 #define TOPOLOGY_CALOTOPOLOGY_CALOSUBDETECTORTOPOLOGY_H 1
3 
7 
8 #include <vector>
9 
18 public:
24  virtual bool valid(const DetId& /*id*/) const { return false; };
26  virtual unsigned int detId2denseId(const DetId& /*id*/) const { return 0; }
28  virtual DetId denseId2detId(unsigned int /*denseid*/) const { return DetId(0); }
30  virtual unsigned int ncells() const { return 1; }
32  virtual int topoVersion() const { return 0; }
34  virtual bool denseIdConsistent(int topoVer) const { return topoVer == topoVersion(); }
35 
37  virtual std::vector<DetId> east(const DetId& id) const = 0;
39  virtual std::vector<DetId> west(const DetId& id) const = 0;
41  virtual std::vector<DetId> north(const DetId& id) const = 0;
43  virtual std::vector<DetId> south(const DetId& id) const = 0;
45  virtual std::vector<DetId> up(const DetId& id) const = 0;
47  virtual std::vector<DetId> down(const DetId& id) const = 0;
48 
49  // interface valid for most subdetectors
50  // see for instance RecoCaloTools/Navigation/interface/CaloNavigator.h
51  virtual DetId goEast(const DetId& id) const {
52  std::vector<DetId> ids = east(id);
53  return ids.empty() ? DetId() : ids[0];
54  }
55  virtual DetId goWest(const DetId& id) const {
56  std::vector<DetId> ids = west(id);
57  return ids.empty() ? DetId() : ids[0];
58  }
59  virtual DetId goNorth(const DetId& id) const {
60  std::vector<DetId> ids = north(id);
61  return ids.empty() ? DetId() : ids[0];
62  }
63  virtual DetId goSouth(const DetId& id) const {
64  std::vector<DetId> ids = south(id);
65  return ids.empty() ? DetId() : ids[0];
66  }
67  virtual DetId goUp(const DetId& id) const {
68  std::vector<DetId> ids = up(id);
69  return ids.empty() ? DetId() : ids[0];
70  }
71  virtual DetId goDown(const DetId& id) const {
72  std::vector<DetId> ids = down(id);
73  return ids.empty() ? DetId() : ids[0];
74  }
75 
77  virtual std::vector<DetId> getNeighbours(const DetId& id, const CaloDirection& dir) const {
78  std::vector<DetId> aNullVector;
79  switch (dir) {
80  case NONE:
81  return aNullVector;
82  break;
83  case SOUTH:
84  return south(id);
85  break;
86  case NORTH:
87  return north(id);
88  break;
89  case EAST:
90  return east(id);
91  break;
92  case WEST:
93  return west(id);
94  break;
95  default:
96  throw cms::Exception("getNeighboursError") << "Unsopported direction";
97  }
98  return aNullVector;
99  }
100 
102  virtual std::vector<DetId> getWindow(const DetId& id, const int& northSouthSize, const int& eastWestSize) const;
103 
105  virtual std::vector<DetId> getAllNeighbours(const DetId& id) const { return getWindow(id, 3, 3); }
106 
107 protected:
108  typedef std::pair<int, int> Coordinate;
109 
110  struct CellInfo {
111  bool visited;
112 
114 
116 
117  CellInfo(bool a_visited, const DetId& a_cell) : visited(a_visited), cell(a_cell) {}
118  };
119 
120  inline Coordinate getNeighbourIndex(const Coordinate& coord, const CaloDirection& dir) const {
121  switch (dir) {
122  case NORTH:
123  return Coordinate(coord.first, coord.second + 1);
124  case SOUTH:
125  return Coordinate(coord.first, coord.second - 1);
126 
127  case EAST:
128  return Coordinate(coord.first + 1, coord.second);
129  case WEST:
130  return Coordinate(coord.first - 1, coord.second);
131 
132  default:
133  throw cms::Exception("getWindowError") << "Unsopported direction";
134  }
135  }
136 };
137 
138 #endif
virtual DetId goNorth(const DetId &id) const
virtual DetId goUp(const DetId &id) const
virtual DetId goDown(const DetId &id) const
virtual std::vector< DetId > west(const DetId &id) const =0
virtual ~CaloSubdetectorTopology()
virtual destructor
virtual std::vector< DetId > getAllNeighbours(const DetId &id) const
virtual bool valid(const DetId &) const
is this detid present in the Topology?
virtual DetId goSouth(const DetId &id) const
Coordinate getNeighbourIndex(const Coordinate &coord, const CaloDirection &dir) const
virtual bool denseIdConsistent(int topoVer) const
return whether this topology is consistent with the numbering in the given topology ...
virtual unsigned int detId2denseId(const DetId &) const
return a linear packed id
CellInfo(bool a_visited, const DetId &a_cell)
virtual DetId goEast(const DetId &id) const
virtual std::vector< DetId > getWindow(const DetId &id, const int &northSouthSize, const int &eastWestSize) const
virtual std::vector< DetId > getNeighbours(const DetId &id, const CaloDirection &dir) const
virtual std::vector< DetId > north(const DetId &id) const =0
Definition: DetId.h:17
virtual std::vector< DetId > up(const DetId &id) const =0
virtual unsigned int ncells() const
return a count of valid cells (for dense indexing use)
virtual std::vector< DetId > south(const DetId &id) const =0
virtual DetId goWest(const DetId &id) const
virtual int topoVersion() const
return a version which identifies the given topology
CaloDirection
Codes the local directions in the cell lattice.
Definition: CaloDirection.h:9
virtual DetId denseId2detId(unsigned int) const
return a linear packed id
Definition: TkAlStyle.h:43
std::pair< int, int > Coordinate
CaloSubdetectorTopology()
standard constructor
virtual std::vector< DetId > east(const DetId &id) const =0
virtual std::vector< DetId > down(const DetId &id) const =0