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>
19 public:
25  virtual bool valid(const DetId& /*id*/) const { return false; };
27  virtual std::vector<DetId> east(const DetId& id) const = 0;
29  virtual std::vector<DetId> west(const DetId& id) const = 0;
31  virtual std::vector<DetId> north(const DetId& id) const = 0;
33  virtual std::vector<DetId> south(const DetId& id) const = 0;
35  virtual std::vector<DetId> up(const DetId& id) const = 0;
37  virtual std::vector<DetId> down(const DetId& id) const = 0;
39  virtual std::vector<DetId> getNeighbours(const DetId& id, const CaloDirection& dir) const
40  {
41  std::vector<DetId> aNullVector;
42  switch(dir)
43  {
44  case NONE:
45  return aNullVector;
46  break;
47  case SOUTH:
48  return south(id);
49  break;
50  case NORTH:
51  return north(id);
52  break;
53  case EAST:
54  return east(id);
55  break;
56  case WEST:
57  return west(id);
58  break;
59  default:
60  throw cms::Exception("getNeighboursError") << "Unsopported direction";
61  }
62  return aNullVector;
63  }
64 
66  virtual std::vector<DetId> getWindow(const DetId& id, const int& northSouthSize, const int& eastWestSize) const;
67 
69  virtual std::vector<DetId> getAllNeighbours(const DetId& id) const
70  {
71  return getWindow(id,3,3);
72  }
73 
74  protected:
75  typedef std::pair<int,int> Coordinate;
76 
77  struct CellInfo
78  {
79  bool visited;
80 
82 
83  CellInfo() :
84  visited(false)
85  {
86  }
87 
88  CellInfo(bool a_visited, const DetId &a_cell) :
89  visited(a_visited),
90  cell(a_cell)
91  {
92  }
93  };
94 
95  inline Coordinate getNeighbourIndex(const Coordinate &coord, const CaloDirection& dir) const
96  {
97  switch (dir)
98  {
99  case NORTH: return Coordinate(coord.first,coord.second + 1);
100  case SOUTH: return Coordinate(coord.first,coord.second - 1);
101 
102  case EAST: return Coordinate(coord.first + 1,coord.second);
103  case WEST: return Coordinate(coord.first - 1,coord.second);
104 
105  default:
106  throw cms::Exception("getWindowError") << "Unsopported direction";
107  }
108  }
109 
110 };
111 
112 
113 #endif
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 std::vector< DetId > west(const DetId &id) const =0
virtual ~CaloSubdetectorTopology()
virtual destructor
CellInfo(bool a_visited, const DetId &a_cell)
Coordinate getNeighbourIndex(const Coordinate &coord, const CaloDirection &dir) const
virtual std::vector< DetId > north(const DetId &id) const =0
Definition: DetId.h:20
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 std::vector< DetId > south(const DetId &id) const =0
dbl *** dir
Definition: mlp_gen.cc:35
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