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