test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
CaloSubdetectorTopology.h
Go to the documentation of this file.
1 #ifndef TOPOLOGY_CALOTOPOLOGY_CALOSUBDETECTORTOPOLOGY_H
2 #define TOPOLOGY_CALOTOPOLOGY_CALOSUBDETECTORTOPOLOGY_H 1
3 
4 
8 
9 #include <vector>
10 
12 
21 public:
27  virtual bool valid(const DetId& /*id*/) const { return false; };
29  virtual unsigned int detId2denseId(const DetId& /*id*/) const { return 0; }
31  virtual DetId denseId2detId(unsigned int /*denseid*/) const { return DetId(0); }
33  virtual unsigned int ncells() const { return 1; }
35  virtual int topoVersion() const { return 0; }
37  virtual bool denseIdConsistent(int topoVer) const { return topoVer==topoVersion(); }
38 
40  virtual std::vector<DetId> east(const DetId& id) const = 0;
42  virtual std::vector<DetId> west(const DetId& id) const = 0;
44  virtual std::vector<DetId> north(const DetId& id) const = 0;
46  virtual std::vector<DetId> south(const DetId& id) const = 0;
48  virtual std::vector<DetId> up(const DetId& id) const = 0;
50  virtual std::vector<DetId> down(const DetId& id) const = 0;
51 
52  // interface valid for most subdetectors
53  // see for instance RecoCaloTools/Navigation/interface/CaloNavigator.h
54  virtual DetId goEast(const DetId& id) const {
55  std::vector<DetId> ids = east(id);
56  return ids.empty() ? DetId() : ids[0];
57  }
58  virtual DetId goWest(const DetId& id) const {
59  std::vector<DetId> ids = west(id);
60  return ids.empty() ? DetId() : ids[0];
61  }
62  virtual DetId goNorth(const DetId& id) const {
63  std::vector<DetId> ids = north(id);
64  return ids.empty() ? DetId() : ids[0];
65  }
66  virtual DetId goSouth(const DetId& id) const {
67  std::vector<DetId> ids = south(id);
68  return ids.empty() ? DetId() : ids[0];
69  }
70  virtual DetId goUp(const DetId& id) const {
71  std::vector<DetId> ids = up(id);
72  return ids.empty() ? DetId() : ids[0];
73  }
74  virtual DetId goDown(const DetId& id) const {
75  std::vector<DetId> ids = down(id);
76  return ids.empty() ? DetId() : ids[0];
77  }
78 
79 
81  virtual std::vector<DetId> getNeighbours(const DetId& id, const CaloDirection& dir) const
82  {
83  std::vector<DetId> aNullVector;
84  switch(dir)
85  {
86  case NONE:
87  return aNullVector;
88  break;
89  case SOUTH:
90  return south(id);
91  break;
92  case NORTH:
93  return north(id);
94  break;
95  case EAST:
96  return east(id);
97  break;
98  case WEST:
99  return west(id);
100  break;
101  default:
102  throw cms::Exception("getNeighboursError") << "Unsopported direction";
103  }
104  return aNullVector;
105  }
106 
108  virtual std::vector<DetId> getWindow(const DetId& id, const int& northSouthSize, const int& eastWestSize) const;
109 
111  virtual std::vector<DetId> getAllNeighbours(const DetId& id) const
112  {
113  return getWindow(id,3,3);
114  }
115 
116  protected:
117  typedef std::pair<int,int> Coordinate;
118 
119  struct CellInfo
120  {
121  bool visited;
122 
124 
125  CellInfo() :
126  visited(false)
127  {
128  }
129 
130  CellInfo(bool a_visited, const DetId &a_cell) :
131  visited(a_visited),
132  cell(a_cell)
133  {
134  }
135  };
136 
137  inline Coordinate getNeighbourIndex(const Coordinate &coord, const CaloDirection& dir) const
138  {
139  switch (dir)
140  {
141  case NORTH: return Coordinate(coord.first,coord.second + 1);
142  case SOUTH: return Coordinate(coord.first,coord.second - 1);
143 
144  case EAST: return Coordinate(coord.first + 1,coord.second);
145  case WEST: return Coordinate(coord.first - 1,coord.second);
146 
147  default:
148  throw cms::Exception("getWindowError") << "Unsopported direction";
149  }
150  }
151 
152 };
153 
154 
155 #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 > getNeighbours(const DetId &id, const CaloDirection &dir) const
virtual std::vector< DetId > getAllNeighbours(const DetId &id) const
std::pair< int, int > Coordinate
virtual int topoVersion() const
return a version which identifies the given topology
virtual std::vector< DetId > west(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 std::vector< DetId > north(const DetId &id) const =0
virtual DetId goDown(const DetId &id) const
Definition: DetId.h:18
virtual std::vector< DetId > up(const DetId &id) const =0
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 bool denseIdConsistent(int topoVer) const
return whether this topology is consistent with the numbering in the given topology ...
virtual std::vector< DetId > south(const DetId &id) const =0
dbl *** dir
Definition: mlp_gen.cc:35
volatile std::atomic< bool > shutdown_flag false
CaloDirection
Codes the local directions in the cell lattice.
Definition: CaloDirection.h:9
CaloSubdetectorTopology()
standard constructor
virtual std::vector< DetId > east(const DetId &id) const =0
virtual std::vector< DetId > down(const DetId &id) const =0