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
CaloSubdetectorTopology::CellInfo::cell
DetId cell
Definition: CaloSubdetectorTopology.h:113
CaloDirection
CaloDirection
Codes the local directions in the cell lattice.
Definition: CaloDirection.h:9
CaloDirection.h
funct::false
false
Definition: Factorize.h:29
CaloSubdetectorTopology::goNorth
virtual DetId goNorth(const DetId &id) const
Definition: CaloSubdetectorTopology.h:59
CaloSubdetectorTopology::east
virtual std::vector< DetId > east(const DetId &id) const =0
CaloSubdetectorTopology::goUp
virtual DetId goUp(const DetId &id) const
Definition: CaloSubdetectorTopology.h:67
CaloSubdetectorTopology::CaloSubdetectorTopology
CaloSubdetectorTopology()
standard constructor
Definition: CaloSubdetectorTopology.h:20
CaloSubdetectorTopology::goDown
virtual DetId goDown(const DetId &id) const
Definition: CaloSubdetectorTopology.h:71
CaloSubdetectorTopology::~CaloSubdetectorTopology
virtual ~CaloSubdetectorTopology()
virtual destructor
Definition: CaloSubdetectorTopology.h:22
CaloSubdetectorTopology::getAllNeighbours
virtual std::vector< DetId > getAllNeighbours(const DetId &id) const
Definition: CaloSubdetectorTopology.h:105
CaloSubdetectorTopology::valid
virtual bool valid(const DetId &) const
is this detid present in the Topology?
Definition: CaloSubdetectorTopology.h:24
CaloSubdetectorTopology::denseIdConsistent
virtual bool denseIdConsistent(int topoVer) const
return whether this topology is consistent with the numbering in the given topology
Definition: CaloSubdetectorTopology.h:34
CaloSubdetectorTopology::west
virtual std::vector< DetId > west(const DetId &id) const =0
DetId
Definition: DetId.h:17
CaloSubdetectorTopology::goSouth
virtual DetId goSouth(const DetId &id) const
Definition: CaloSubdetectorTopology.h:63
EAST
Definition: CaloDirection.h:14
NORTH
Definition: CaloDirection.h:18
CaloSubdetectorTopology::detId2denseId
virtual unsigned int detId2denseId(const DetId &) const
return a linear packed id
Definition: CaloSubdetectorTopology.h:26
CaloSubdetectorTopology::goEast
virtual DetId goEast(const DetId &id) const
Definition: CaloSubdetectorTopology.h:51
CaloSubdetectorTopology::getNeighbours
virtual std::vector< DetId > getNeighbours(const DetId &id, const CaloDirection &dir) const
Definition: CaloSubdetectorTopology.h:77
CaloSubdetectorTopology::getNeighbourIndex
Coordinate getNeighbourIndex(const Coordinate &coord, const CaloDirection &dir) const
Definition: CaloSubdetectorTopology.h:120
CaloSubdetectorTopology::ncells
virtual unsigned int ncells() const
return a count of valid cells (for dense indexing use)
Definition: CaloSubdetectorTopology.h:30
CaloSubdetectorTopology
Definition: CaloSubdetectorTopology.h:17
CaloSubdetectorTopology::south
virtual std::vector< DetId > south(const DetId &id) const =0
CaloSubdetectorTopology::north
virtual std::vector< DetId > north(const DetId &id) const =0
CaloSubdetectorTopology::goWest
virtual DetId goWest(const DetId &id) const
Definition: CaloSubdetectorTopology.h:55
CaloSubdetectorTopology::CellInfo::CellInfo
CellInfo(bool a_visited, const DetId &a_cell)
Definition: CaloSubdetectorTopology.h:117
CaloSubdetectorTopology::getWindow
virtual std::vector< DetId > getWindow(const DetId &id, const int &northSouthSize, const int &eastWestSize) const
Definition: CaloSubdetectorTopology.cc:4
WEST
Definition: CaloDirection.h:15
DetId.h
Exception
Definition: hltDiff.cc:246
CaloSubdetectorTopology::topoVersion
virtual int topoVersion() const
return a version which identifies the given topology
Definition: CaloSubdetectorTopology.h:32
CaloSubdetectorTopology::up
virtual std::vector< DetId > up(const DetId &id) const =0
CaloSubdetectorTopology::denseId2detId
virtual DetId denseId2detId(unsigned int) const
return a linear packed id
Definition: CaloSubdetectorTopology.h:28
NONE
Definition: TkAlStyle.cc:47
Exception.h
CaloSubdetectorTopology::CellInfo
Definition: CaloSubdetectorTopology.h:110
CaloSubdetectorTopology::Coordinate
std::pair< int, int > Coordinate
Definition: CaloSubdetectorTopology.h:108
CaloSubdetectorTopology::CellInfo::CellInfo
CellInfo()
Definition: CaloSubdetectorTopology.h:115
SOUTH
Definition: CaloDirection.h:11
CaloSubdetectorTopology::CellInfo::visited
bool visited
Definition: CaloSubdetectorTopology.h:111
CaloSubdetectorTopology::down
virtual std::vector< DetId > down(const DetId &id) const =0
DeadROC_duringRun.dir
dir
Definition: DeadROC_duringRun.py:23