Go to the documentation of this file.00001 #ifndef TOPOLOGY_CALOTOPOLOGY_CALOSUBDETECTORTOPOLOGY_H
00002 #define TOPOLOGY_CALOTOPOLOGY_CALOSUBDETECTORTOPOLOGY_H 1
00003
00004
00005 #include "DataFormats/DetId/interface/DetId.h"
00006 #include "Geometry/CaloTopology/interface/CaloDirection.h"
00007 #include "FWCore/Utilities/interface/Exception.h"
00008
00009 #include <vector>
00018 class CaloSubdetectorTopology {
00019 public:
00021 CaloSubdetectorTopology() {};
00023 virtual ~CaloSubdetectorTopology() { }
00025 virtual bool valid(const DetId& ) const { return false; };
00027 virtual std::vector<DetId> east(const DetId& id) const = 0;
00029 virtual std::vector<DetId> west(const DetId& id) const = 0;
00031 virtual std::vector<DetId> north(const DetId& id) const = 0;
00033 virtual std::vector<DetId> south(const DetId& id) const = 0;
00035 virtual std::vector<DetId> up(const DetId& id) const = 0;
00037 virtual std::vector<DetId> down(const DetId& id) const = 0;
00039 virtual std::vector<DetId> getNeighbours(const DetId& id, const CaloDirection& dir) const
00040 {
00041 std::vector<DetId> aNullVector;
00042 switch(dir)
00043 {
00044 case NONE:
00045 return aNullVector;
00046 break;
00047 case SOUTH:
00048 return south(id);
00049 break;
00050 case NORTH:
00051 return north(id);
00052 break;
00053 case EAST:
00054 return east(id);
00055 break;
00056 case WEST:
00057 return west(id);
00058 break;
00059 default:
00060 throw cms::Exception("getNeighboursError") << "Unsopported direction";
00061 }
00062 return aNullVector;
00063 }
00064
00066 virtual std::vector<DetId> getWindow(const DetId& id, const int& northSouthSize, const int& eastWestSize) const;
00067
00069 virtual std::vector<DetId> getAllNeighbours(const DetId& id) const
00070 {
00071 return getWindow(id,3,3);
00072 }
00073
00074 protected:
00075 typedef std::pair<int,int> Coordinate;
00076
00077 struct CellInfo
00078 {
00079 bool visited;
00080
00081 DetId cell;
00082
00083 CellInfo() :
00084 visited(false)
00085 {
00086 }
00087
00088 CellInfo(bool a_visited, const DetId &a_cell) :
00089 visited(a_visited),
00090 cell(a_cell)
00091 {
00092 }
00093 };
00094
00095 inline Coordinate getNeighbourIndex(const Coordinate &coord, const CaloDirection& dir) const
00096 {
00097 switch (dir)
00098 {
00099 case NORTH: return Coordinate(coord.first,coord.second + 1);
00100 case SOUTH: return Coordinate(coord.first,coord.second - 1);
00101
00102 case EAST: return Coordinate(coord.first + 1,coord.second);
00103 case WEST: return Coordinate(coord.first - 1,coord.second);
00104
00105 default:
00106 throw cms::Exception("getWindowError") << "Unsopported direction";
00107 }
00108 }
00109
00110 };
00111
00112
00113 #endif